Error compiling a specialized template in Devc++
http://www.cplusplus.com/doc/tutorial/templates.html
I tried to compile the example given on there about template specializations (just added a pause at the end), but the compiler doesn't seem to like it for some reason.
Code:
// template specialization
#include <iostream>
using namespace std;
template <class T>
class container {
T element;
public:
container (T arg) {element=arg;}
T increase () {return ++element;}
};
template <>
class container <char> {
char element;
public:
container (T arg) {element=arg;}
char uppercase ();
};
template <>
char container<char>::uppercase()
{
if ((element>='a')&&(element<='z'))
element+='A'-'a';
return element;
}
int main () {
container<int> myint (7);
container<char> mychar ('j');
cout << myint.increase() << endl;
cout << mychar.uppercase() << endl;
system("pause");
return 0;
}
Can someone please tell me what is wrong here?
Does the compiler has problems with the empty <> on the template definition? Is this a compiler or code problem?
Thank you in advance :o