[C++] Template specialisation
Hello!
I've understood the principles of template specialization but I'm wondering how it is possible to specialize a function template that looks like this :
template<class T>
const char * getType() { return "unknown type"; }
In this example, there is no occurrence of "T" in the function template declaration, so I'm somewhat confused about how I can specialize it.
Could anyone give me an example?
template<class T>const char * getType() { return "unknown type"; }template<>const char * getType<float>() { return "float"; }
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement