This is what I'm trying to compile with GCC 3.4.4 under Linux. The
error I'm getting is:
g++ -s -O3 -Wall class2.cc -o class2
class2.cc:25: error: template-id `uppercase<>' for `char
container<char>::uppercase()' does not match any template declaration
class2.cc:25: error: invalid function declaration make: *** [class2]
Error 1
What's wrong with it? The code is as below. Thanks for any hints
offered.
#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 (char 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;
return 0;
}
--
http://www.munted.org.uk
"Honestly, what can I possibly say to get you into my bed?" - Anon.