#include <iostream>
usingnamespace std;
int main()
{
class Game; //Prototype declaration
Game object;
}
class Game // And the class
{
public:
Game() { } ;
~Game() { } ;
};
This gives the error:
aggregate 'main()::Game object' has incomplete type and cannot be defined|
It works fine if I declare the class before the main function, and don't use any prototype.
Where is the problem?
Edit:
I just found out what the problem was. I'm not allowed to use a forward declaration to create an object.
I should have found this by searching, but I wasn't aware that prototypes for classes are called forward declarations.