오후 7:47 1999-09-21 조경민
템플리트 in DLL
------------------------
DLL.h

#define DLLEXP        __declspec(dllexport)

template < class T > int DLLEXP big(T);

template int DLLEXP big(int);
template int DLLEXP big(char);

template <class T>
class DLLEXP CMy  
{
public:
        CMy();
        virtual ~CMy();
        
        T data;
        T get();
        void set(T a);

};

template class DLLEXP CMy<int>;


DLL.cpp

template <class T>
int DLLEXP big(T a)
{
        return a;
}

template <class T>
CMy<T>::CMy()
{
        data = 0;
}

template <class T>
CMy<T>::~CMy()
{
}

template <class T>
T CMy<T>::get()
{
        return data;
}


template <class T>
void CMy<T>::set(T a)
{
        data = a;
}



쓰는 부분의 dll.h

#define DLLEXP        __declspec(dllimport)

template < class T > int  DLLEXP  big(T);

inline template int DLLEXP big<int>(int);

template <class T>
class CMy  
{
public:
        CMy(void);
        virtual ~CMy(void);
        
        T data;
        T get();
        void set(T a);

};

//template class CMy<int>;
typedef CMy<int> CIMy;





// 부분도 넣으면 아래 같은 워닝남
warning C4661: '__thiscall CMy<int>::CMy<int>(void)' : no suitable definition provided for explicit template instantiation request
        c:\project\testdd\testddex\my.h(22) : see declaration of 'CMy<int>::CMy<int>'

'KB > MFC/Win32' 카테고리의 다른 글

hook 설명  (0) 2004.03.19
템플리트클래스..  (0) 2004.03.19
간단 콘솔제어  (0) 2004.03.19
여러컨트롤의 포커스를 바꾸는 방법  (0) 2004.03.19
[ActiveX] 엑티브 컨트롤 웹 페이지 만들기  (0) 2004.03.19

+ Recent posts