Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   templates specialisation (http://www.go4expert.com/forums/templates-specialisation-t1662/)

altafahmed2k4 18Oct2006 07:35

templates specialisation
i m using borlands turbo c++ ide compiler dos based

i entered thw following code

// template specialization
#include <iostream>
using namespace std;

template <class T>
class container {
    T element;
    container (T arg) {element=arg;}
    T increase () {return ++element;}

template <>Encountered error "invalid argument list"
class container <char> {
    char element;
    container (T arg) {element=arg;}
    char uppercase ();

template <>Encountered error "invalid argument list"
char container<char>::uppercase()
  if ((element>='a')&&(element<='z'))
  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

shabbir 18Oct2006 10:08

Re: templates specialisation
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

altafahmed2k4 18Oct2006 21:57

Re: templates specialisation
Then is it like that

template specialisation is not possible in Borlands Turbo C++ version 3.0

if yes please direct me.

shabbir 19Oct2006 10:03

Re: templates specialisation
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

altafahmed2k4 19Oct2006 22:45

Re: templates specialisation
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

shabbir 21Oct2006 09:09

Re: templates specialisation
Mastering the compiler is not what will help you. Try using the latest compilers from GCC(on Linux Systems) or MS (on Windows)

All times are GMT +5.5. The time now is 17:41.