File main2.cpp:
#include "poly2.h"
int main(){
Poly<int> cze;
return 0;
}
File poly2.h:
template <class T>
class Poly {
public:
Poly();
};
File poly2.cpp:
#include "poly2.h"
template<class T>
Poly<T>::Poly() {
}
Error during compilation:
src$ g++ poly2.cpp main2.cpp -o poly
/tmp/ccXvKH3H.o: In function `main':
main2.cpp:(.text+0x11): undefined reference to `Poly<int>::Poly()'
collect2: ld returned 1 exit status
I'm trying to compile above code, but there are errors during compilation. What should be fixed to compile constructor with template parameter?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…