VC不支持分離編譯模式.
不支持export關鍵字.
要使用模板
#include "temp.h"
#include "temp.cpp"
都要引用這兩個文件.
#ifndef TEMP_H
#define TEMP_H
#include <typeinfo>
#include <iostream>
using namespace std;
template<typename T,int size>class MyTemp
{
?? private:
??? int m_size;
??? T m_Value;
?? public:
??? MyTemp();
??? void Print();
};
#endif
#include "temp.h"
template<typename T,int size>MyTemp<T,size>::MyTemp():m_size(size)
{
}
template<typename T,int size>void MyTemp<T,size>::Print()
{
??? cout<<typeid(T).name()<<endl;
?????? cout<<m_size<<endl;
}
#include "temp.h"
#include "temp.cpp"
int main()
{
???? MyTemp<string,100>myob;
? myob.Print();
???? return 1;
}