You have to use forward declaration.
The compiler read cprotocol.h,
then cpacket.h through include directive,
then cprotocol again through include directive, but skip it because of #ifndef
then read CPacket definition and CPtrotocol is not defined!
Just declare the class without defining it instead of #include directive:
#ifndef CPROTOCOL_H
#define CPROTOCOL_H
class CPacket; //forward declaration
class CProtocol
{
private:
CPacket *mPacketList;
public:
CProtocol();
};
#endif // CPROTOCOL_H
#ifndef CPROTOCOL_H
#define CPROTOCOL_H
class CPacket; //forward declaration
class CProtocol
{
private:
CPacket *mPacketList;
public:
CProtocol();
};
#endif // CPROTOCOL_H
To copy to clipboard, switch view to plain text mode
#ifndef CPACKET_H
#define CPACKET_H
class CProtocol; //forward declaration
class CPacket
{
private:
CProtocol *parent;
public:
CPacket();
};
#endif // CPACKET_H
#ifndef CPACKET_H
#define CPACKET_H
class CProtocol; //forward declaration
class CPacket
{
private:
CProtocol *parent;
public:
CPacket();
};
#endif // CPACKET_H
To copy to clipboard, switch view to plain text mode
Bookmarks