hi i m using borlands turbo c++ ide compiler dos based i entered thw following code 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 <>[B]Encountered error "invalid argument list"[/B] class container <char> { char element; public: container (T arg) {element=arg;} char uppercase (); }; template <>[B]Encountered error "invalid argument list"[/B] 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; } also i am not able to use namespace std; may i know what is the reason altafahmed2k4@yahoo.co.in
Your code is absolutely fine as far as compilation should go but its just Turbo C3 does not support it in a manner you have written it. I think you should be doing something like template <char>. Regarding namespace turboC3 does not support namespaces and its done in MS compilers
Then is it like that template specialisation is not possible in Borlands Turbo C++ version 3.0 if yes please direct me.
Probably you cannot but I would suggest you not using the TC3 unless and until you are bound to be using that as lots of things dont work correctly in TC3
Thank u shabbir i tried using bloodshed compiler the code is not working there too can you direct me to how i can master this compiler any specific site
Mastering the compiler is not what will help you. Try using the latest compilers from GCC(on Linux Systems) or MS (on Windows)