In C++ there is a rule that between classes, you can't use anything before you have declared it. This doesn't apply within a class (you can call a method in the same class that you have not declared yet), but it does apply between classes (you cannot call a method in another class that you have not declared yet).
So, for instance, saying "class gameClass;" tells the compiler that "there is a class named gameClass", and this lets you do a few things with it, such as declaring extern variables of that type. However, you have not yet declared the fields or methods of gameClass, so you cannot yet refer to those.
The usual pattern in C++ is to place in a header file the definitions of all classes with their fields and methods, but not including the bodies of the methods (unless they are very trivial methods). This gets everything declared properly, and then in the source file you place the bodies of the methods, where you're free to call other methods of any classes, since everything has been declared already.
// In a header file
class gameClass
{
public:
void restart(); // Note, the body of the function is NOT here
...
int level; // Fields of the class are defined here too
};
extern gameClass gameObject;
class enemyBubble
{
public:
void respawn();
void checkCol();
...
int health;
float speed;
...
};
extern enemyBubble enemy[enemies];
// Now in a source file that #includes the previous header...
// Define the variables we previously declared; this actually creates the variables
gameClass gameObject;
enemyBubble enemy[enemies];
void gameClass::restart()
{
// Here is the body of the restart method
player.respawn();
for (int i = 0; i < enemies; i++)
{
enemy[i].respawn(); // We can call this here since enemyBubble::respawn() was declared,
// even though its body hasn't been defined yet
enemy[i].speed = 0.1f;
}
}
void enemyBubble::checkCol()
{
...
gameObject.restart(); // We can call this here since gameClass::restart() was declared;
// its body HAS been defined at this point, but that doesn't matter.
}