. Advertisement .
..3..
. Advertisement .
..4..
How to check – c++ incomplete type is not allowed? I have the sample detail:
class Player;
class Ball {
public:
Player& PlayerB;
float ballPosX = 800;
private:
};
class Ball;
class Player {
public:
void doSomething(Ball& ball);
private:
};
While I run it, I found the warning message:
Incomplete type not allowed
That is my question in my midterm exam, and it is urgent. I searched some methods on some websites, but I didn’t get it. I may miss any line or other changes. I appreciate your assistance!
The cause:
The issue happens when compiler finds identifier which is one of the recognized data type nevertheless its definition is not clear at all.
Solution: Put your definitions as the following direction in order to compile the code:
Modified code:
Player.cpp
requires the definition ofBall
class. Simply add#include "Ball.h"
Player.cpp: