怎样将一个特定的模板类导出为DLL?谁能解释清楚
hjgmx 2003-12-29 09:50:44 #ifdef TEST_EXPORTS
#define TEST_API __declspec(dllexport)
#else
#define TEST_API __declspec(dllimport)
#endif
template <class T> CTest
{
public:
T* pValue;
CTest(const T& value)
{
pValue = new T;
*pValue = value;
}
~CTest()
{
delete pValue;
}
};
class TEST_API CMyTest
{
public:
CTest<long> m_Long;
CTest<char> m_Char;
void Show();
};
在VC6下编译,提示告警,warning C4251, class CTest<long>' needs to have dll-interface to be used by clients of class.
可是怎样才能将该特定的模板类导出呢?
上面的程序只是一个说明问题的例子,因为我实际使用的模板类是一个比较复杂的类,没有必要去重写。