I have three files (myClass.h, myClass.cpp, and main.cpp)
//
// myClass.h
#ifndef MYCLASS_H_
#define MYCLASS_H_
template <class element_type>
class myClass
{
public:
myClass();
~myClass();
};
#endif /* MYCLASS_H_ */
//
// myClass.cpp
#include "myClass.h"
template <class element_type>
myClass<element_type>::myClass()
{
}
template <class element_type>
myClass<element_type>::~myClass()
{
}
//
// main.cpp
#include "myClass.h"
int main()
{
myClass<int> classOBJ;
return 0;
}
I tried compiling this in VC++ Express, Dev-Cpp, and Eclipse
All give me roughly the same error. From eclipse
undefined reference to `myClass<int>::~myClass()' main.cpp heapProj 15 C/C++ Problem
undefined reference to `myClass<int>::myClass()' main.cpp heapProj 12 C/C++ Problem
This leads me to believe that I'm coding something wrong, but I just can't track it down for some reason. What's the problem?