I create a class in Vec.h like this:
#include <VECTOR>
using namespace std;
template<class T>
class Vec:public vector<T>
{
public:
Vec():vector<T>(){}
Vec(int s):vector<T>(s){}
T& operator[](int i){return at(i);}
const T& operator[](int i) const {return at(i);}
~Vec();
};
in the main.cpp:
int main(int argc, char* argv[])
{
Vec<int> test(2);
return 0;
}
but when I compile them,it show:
error LNK2001: unresolved external symbol "public: __thiscall Vec<int>::~Vec<int> (void)" (??1?$Vec@H@@QAE@XZ)
Debug/CPlusTest.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
My compilation toos is VC6.0. How can I do?
Update: Sorry! I'd not copy the entire "main.cpp", it should be that:
#include <string>
#include <IOSTREAM>
#include "Vec.h"
using namespace std;
int main(int argc, char* argv[])
{
Vec<int> test(2);
return 0;
}
and now the error is because I dit not realize "~Vec();" so,modify this Vec.h like this:
~Vec(){}
Compiled successfully!