在dll中导入模板类与模板函数
假设我们有一个模板类如下:
template< class T >
class CArray
{
public:
private:
}
template< class T >
CArray< T >::CArray() { m_pData = NULL; }
模板函数如下:
template
void Swap(T& tNum1, T& tNum2)
{
}
#define ALGORITHM_DLL
#else //EXPORT
#define ALGORITHM_DLL
ALGORITHM_DLL void Swap(T& tNum1, T& tNum2)
{
T tTmp;
tTmp = tNum1;
tNum1 = tNum2;
tNum2 = tTmp;
}
#define ALGORITHM_DLL __declspec(dllimport)
#else //EXPORT
#define ALGORITHM_DLL __declspec(dllexport)
ALGORITHM_DLL void Swap(T& tNum1, T& tNum2)
{
T tTmp;
tTmp = tNum1;
tNum1 = tNum2;
tNum2 = tTmp;
}
#ifndef ALGORITHM_EXPORTS
#endif
template< class T >
class ALGORITHM_DLL CArray
{
public:
private:
}
template< class T >
CArray< T >::CArray() {
template
#ifndef ALGORITHM_EXPORTS
#define ALGORITHM_TEMPLATE
#define ALGORITHM_TEMPLATE __declspec(dllexport)
#endif
template< class T >
class ALGORITHM_TEMPLATE CArray
{
public:
private:
}
template< class T >
CArray< T >::CArray() { m_pData = NULL; }
template