template specialization outside of class header

Is it possible to define a template specialization class outide of the class header?
1
2
template <>
char MyObject<char>::getVar(){return Var;}
closed account (zb0S216C)
Yes:

1
2
3
4
5
6
7
8
9
10
template <typename T>
struct X { };

template<>
struct X<char>
{
    X();
};

X<char>::X() { }

Note the absence of template<> before the definition of X's constructor. It's use is not required here, because it's already a complete type after its specialisation.

Wazzak
Last edited on
You are the freakin man! Thanks alot!!
Topic archived. No new replies allowed.