当前位置: 技术问答>linux和unix
想用C++在Linux下实现动态链接,以下是我的代码请帮忙参考,急!
来源: 互联网 发布时间:2015-03-28
本文导语: 公用基类部分:SMSGamePlugin.h #ifndef __SMSGamePlugin_h__ #define __SMSGamePlugin_h__ class CSMSGamePlugin { public: virtual int Initialize(void) = 0; virtual int Load(void) = 0; virtual int Handle(void) = 0; }; #endif 动态链接库头文件:Flower.h #i...
公用基类部分:SMSGamePlugin.h
#ifndef __SMSGamePlugin_h__
#define __SMSGamePlugin_h__
class CSMSGamePlugin
{
public:
virtual int Initialize(void) = 0;
virtual int Load(void) = 0;
virtual int Handle(void) = 0;
};
#endif
动态链接库头文件:Flower.h
#ifndef __Flower_h__
#define __Flower_h__
#include "SMSGamePlugin.h"
CSMSGamePlugin *GetGameObject(void);
class CFlower: public CSMSGamePlugin
{
public:
virtual int Initialize(void);
virtual int Load(void);
virtual int Handle(void);
};
#endif
动态链接库实现文件:Flower.cpp
#include
#include "Flower.h"
CSMSGamePlugin *GetGameObject(void)
{
return(new CFlower());
}
int CFlower::Initialize(void)
{
std::cout
#ifndef __SMSGamePlugin_h__
#define __SMSGamePlugin_h__
class CSMSGamePlugin
{
public:
virtual int Initialize(void) = 0;
virtual int Load(void) = 0;
virtual int Handle(void) = 0;
};
#endif
动态链接库头文件:Flower.h
#ifndef __Flower_h__
#define __Flower_h__
#include "SMSGamePlugin.h"
CSMSGamePlugin *GetGameObject(void);
class CFlower: public CSMSGamePlugin
{
public:
virtual int Initialize(void);
virtual int Load(void);
virtual int Handle(void);
};
#endif
动态链接库实现文件:Flower.cpp
#include
#include "Flower.h"
CSMSGamePlugin *GetGameObject(void)
{
return(new CFlower());
}
int CFlower::Initialize(void)
{
std::cout