当前位置: 技术问答>linux和unix
编译问题,类之间相互引用。
来源: 互联网 发布时间:2016-01-14
本文导语: windows 下没问题,Linux 下一直没解决啊! 程序框架如下: /** * 文件名: MessageFactory.h **/ #ifndef MessageFactory_h #define MessageFactory_h #include "MessageServer.h" class MessageServer ; class MessageFactory { public: MessageFactory(void){} ...
windows 下没问题,Linux 下一直没解决啊!
程序框架如下:
/**
* 文件名: MessageFactory.h
**/
#ifndef MessageFactory_h
#define MessageFactory_h
#include "MessageServer.h"
class MessageServer ;
class MessageFactory
{
public:
MessageFactory(void){}
virtual ~MessageFactory(void){}
virtual void CreateReceiver(int code, MessageServer* server) = 0;
};
#endif
/**
* 文件名: MessageFactoryImpl.h
**/
#ifndef MessageFactoryImpl_h
#define MessageFactoryImpl_h
#include "MessageFactory.h"
class MessageFactoryImpl :public MessageFactory
{
public:
MessageFactoryImpl();
virtual ~MessageFactoryImpl(){}
virtual void CreateReceiver(int code, MessageServer* server);
};
#endif
/**
* 文件名: MessageFactoryImpl.cpp
**/
#include "MessageFactoryImpl.h"
MessageFactoryImpl::MessageFactoryImpl()
{
}
void MessageFactoryImpl::CreateReceiver(int code, MessageServer* server)
{
}
/**
* 文件名: MessageServer.h
**/
#ifndef MessageServer_h
#define MessageServer_h
#include "MessageFactory.h"
class MessageFactory ;
class MessageServer
{
public:
MessageServer();
MessageServer(int udpPort, MessageFactory* factory, long timeout);
virtual ~MessageServer();
};
#endif
/**
* 文件名: MessageServer.cpp
**/
#include "MessageServer.h"
MessageServer::MessageServer()
{
}
MessageServer::MessageServer(int udpPort, MessageFactory* factory, long timeout)
{
}
MessageServer::~MessageServer()
{
}
//:test.cpp
#include
#include "MessageFactoryImpl.h"
#include "MessageServer.h"
using namespace std;
int main()
{
MessageFactoryImpl *a=new MessageFactoryImpl();
MessageServer *b=new MessageServer();
cout
程序框架如下:
/**
* 文件名: MessageFactory.h
**/
#ifndef MessageFactory_h
#define MessageFactory_h
#include "MessageServer.h"
class MessageServer ;
class MessageFactory
{
public:
MessageFactory(void){}
virtual ~MessageFactory(void){}
virtual void CreateReceiver(int code, MessageServer* server) = 0;
};
#endif
/**
* 文件名: MessageFactoryImpl.h
**/
#ifndef MessageFactoryImpl_h
#define MessageFactoryImpl_h
#include "MessageFactory.h"
class MessageFactoryImpl :public MessageFactory
{
public:
MessageFactoryImpl();
virtual ~MessageFactoryImpl(){}
virtual void CreateReceiver(int code, MessageServer* server);
};
#endif
/**
* 文件名: MessageFactoryImpl.cpp
**/
#include "MessageFactoryImpl.h"
MessageFactoryImpl::MessageFactoryImpl()
{
}
void MessageFactoryImpl::CreateReceiver(int code, MessageServer* server)
{
}
/**
* 文件名: MessageServer.h
**/
#ifndef MessageServer_h
#define MessageServer_h
#include "MessageFactory.h"
class MessageFactory ;
class MessageServer
{
public:
MessageServer();
MessageServer(int udpPort, MessageFactory* factory, long timeout);
virtual ~MessageServer();
};
#endif
/**
* 文件名: MessageServer.cpp
**/
#include "MessageServer.h"
MessageServer::MessageServer()
{
}
MessageServer::MessageServer(int udpPort, MessageFactory* factory, long timeout)
{
}
MessageServer::~MessageServer()
{
}
//:test.cpp
#include
#include "MessageFactoryImpl.h"
#include "MessageServer.h"
using namespace std;
int main()
{
MessageFactoryImpl *a=new MessageFactoryImpl();
MessageServer *b=new MessageServer();
cout