使用__declspec(export)导出C++类到DLL

使用举例: 
// File: SimpleDLLClass.h
#ifdef SIMPLEDLL_EXPORT //在DLL工程属性-c/c++-预处理器-预处理器定义中添加此宏定义
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif
class DLL_EXPORT SimpleDLLClass
{
public:
 SimpleDLLClass();
 virtual ~SimpleDLLClass();
 virtual getValue() { return m_nValue;};
private:
 int m_nValue;
};
// File: SimpleDLLClass.cpp
#include "SimpleDLLClass.h"
SimpleDLLClass::SimpleDLLClass()
{
 m_nValue=0;
}
SimpleDLLClass::~SimpleDLLClass()
{
}

 

 

posted @ 2014-02-10 14:27  酷熊  阅读(1488)  评论(0编辑  收藏  举报