Compile error in c++ while doing something new

Associate
Joined
6 Sep 2007
Posts
2
Hi, I'm playing with passing a reference to a class into one of the class' sub classes, and things are looking dire. Could someone please let me know where I'm going wrong before I lose what's left of my hair!

So, the GAME class contains an ARMY class. One of ARMY's member functions needs access to a few bits and bobs in GAME, so I've got:

Inside GAME.cpp

Code:
if (myArmy->move(*this)){ some stuff }

(the myArmy->move() bit worked before when I didn't try to pass anything in, so there's no problem with pointer initialisation elsewhere for the army)

Inside ARMY.h

Code:
bool move(const GAME& game);

Inside ARMY.cpp

Code:
bool ARMY::move(const GAME& game)
{
	// if it's got somewhere new move to
	if (hasDest){

		// move in the correct direction
		bool mapUpdateNeeded=0;

		// right
		if (destX > mapX && 
			game.getLandType(mapX+1, mapY) !=0 &&
			game.getLandType(maxX+1, mapY) !=3){
				mapX++;
				mapUpdateNeeded = 1;  
		}  // etc etc for other directions
}

Compiling gives a number of lovely errors, the first being
conq\ARMY.h(61) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
which is pointing towards the code provided above from ARMY.h. ARMY.h contains a #include for GAME.h, which leaves me totally and embarrassingly stuck.

Could someone give me a little guidance please? As usual, no need to do my work for me, but a push in the right direction would be appreciated.

Thanks.
 
Back
Top Bottom