Reputation: 539
I have this code:
#ifndef AI_H
#define AI_H
void BuildTree(Board b);
int getMove();
void acceptMove(int);
#endif
and the cpp file:
#include "AI.h"
#include "Board.h"
void BuildTree(Board b)
{
}
int getMove()
{
return 0;
}
void acceptMove(int)
{
}
I am getting an error because of the paramater Board b
in the header file.
the error is:
Error 1 error C2065: 'Board' : undeclared identifier
why is it not accepting an object?? I want the function to receive an object by value, not reference.
Upvotes: 0
Views: 50
Reputation: 40070
The compiler is complaining about Board: it does not know what is it. You must define (not only declare) it to be able to use an object of that type (e.g. taking it as parameter).
You can solve your issue by #include
ing the header file defining Board
:
#include "Board.h"
Upvotes: 1
Reputation: 1433
Just include Board.h
in ai.h
:
#ifndef AI_H
#define AI_H
#include "Board.h"
void BuildTree(Board b);
int getMove();
void acceptMove(int);
#endif
Upvotes: 2