I have an abstract base Object
class and two derived classes from it: Paddle
and Ball
. Paddle
's constructor accepts as a parameter a pointer to Ball
so that i can get its position to calculate the paddle movement:
Paddle::Paddle(Vec location, Vec size, float AIspeed, Ball* prtBall)
: Object(location, size)
{
/* ... */
gameBall = ptrBall;
}
IntelliSense does not flag this as invalid, but whenever I compile the code, VS2013 unexpectedly throws the following errors:
1>\object\paddle.h(8): error C2061: syntax error : identifier 'Ball'
1>\object\paddle.h(43): error C2143: syntax error : missing ';' before '*'
1>\object\paddle.h(43): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>\object\paddle.h(18): error C2065: 'gameBall' : undeclared identifier
1>\object\paddle.h(18): error C2065: 'ptrBall' : undeclared identifier
1>\object\paddle.h(30): error C2065: 'gameBall' : undeclared identifier
The first two are particularly interesting... From the looks of it, the compiler is not recognizing that Ball*
is a type. Line 8 is the one above and these are lines 40-44:
private:
void Foo();
Ball* gameBall;
float bar;
At first I was thinking that I forgot to include Ball
's definition in the file paddle.h
. But this is not the case. Is what I`m doing correct or is there a flaw currently overlooked?