Implementing templated class constructors

Sep 13, 2008 at 3:41pm
My nice message was acidently deleted when pressing the backspace by acident, so here is the brief...

abstraction.h
1
2
3
4
5
6
7
template<class T>
class Class
{
public:
 Class();
 ~Class();
};


implementation.h
1
2
3
4
5
6
7
8
9
#include "abstraction.h"
template<class T>
Class<T>::Class()
{
}
template<class T>
Class<T>::~Class()
{
}



Error messages when creating an instance of the class:
error LNK2019: unresolved external symbol "public: __thiscall Class<char >::Class<char>(void)" ...
error LNK2019: unresolved external symbol "public: __thiscall Class<char >::~Class<char>(void)" ...

Sep 13, 2008 at 3:52pm
Ahh, note that if I implement constructor like this

Class()
{
}

It works...I mean, wtf!

I'm using MSVS9

Take care guys
Sep 13, 2008 at 6:05pm
Hyea, templates are compiled on demand so I cant use them outside of the .cpp that holds the main function
Sep 13, 2008 at 7:19pm
Yeah. You see... VC++ has this thing...
http://www.cplusplus.com/forum/windows/3158/
Topic archived. No new replies allowed.