A
Aarti
Say I have a class template as follows
template<typename T>
class foo
{
public:
void test();
};
template<typename T>
void foo<T>::test()
{
// function implementation
}
Now if i want to specialize it for say strings, I would do it as
follows
template<>
class foo<string>
{
public:
void test();
};
template<> //Gives a error "function cannot be specialized"
void foo<string>::test()
{
// function implementation
}
My question is why do I need to omit the "template<> " for functions
of specialized template class? I am trying this with Visual C++
Express 2005 edition.
template<typename T>
class foo
{
public:
void test();
};
template<typename T>
void foo<T>::test()
{
// function implementation
}
Now if i want to specialize it for say strings, I would do it as
follows
template<>
class foo<string>
{
public:
void test();
};
template<> //Gives a error "function cannot be specialized"
void foo<string>::test()
{
// function implementation
}
My question is why do I need to omit the "template<> " for functions
of specialized template class? I am trying this with Visual C++
Express 2005 edition.