Well, this is more of a C++ problem, not a game programming problem. Anyway :
I can think of a couple of ways to do this ( I have no idea if they'll work! ):
The 1st method
When defining the interface for Dog, use references of and pointers to Cat. And forward declare cat, before Dog's interface.
When implementing Dog, include the Cat interface.
The 2nd method
Make a base class that has methods for messaging and interaction. Pass Dog to Cat as an instance of the base class, pass cat to dog as an instance of the base class.
For example :
Code:
// object.h
class T_Object
{
public:
virtual void Action( int action,void *pParameters ) = 0;
public:
enum
{
ACT_MOVE, // cat and dog
ACT_ATTACK, // cat and dog
ACT_BARK, // dog only
ACT_BITE // cat and dog
};
};
// Dog.h
#include "object.h"
class T_Dog : public T_Object
{
private:
virtual void Action( int action,void *pParameters )
{
switch( action )
{
case ACT_BARK:
Bark( pParameters );
break;
case ACT_BITE:
Bite( pParameters );
break;
case ACT_MOVE:
Move( pParameters );
break;
.
.
.
}
}
void Bark( void *pParameters )
{
// Cast parameter to whatever you want
struct T_BarkParam
{
int volume,length;
};
T_BarkParam *pBarkParam = (T_BarkParam*)pParameters;
// Do whatever you want with the bark parameters and return
Snd_PlaySound( "bark.wav",pBarkParam->volume,pBarkParam->length );
}
.
.
.
};
// Cat.h
#include "object.h"
// Same as dog.h