Afficher un message
Vieux 21/02/2008, 11h55   #1
Pallav singh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Class Template with Specialization code Giving Error

Hi

I am getting error in compiling this code .......Unable to find error
Kindly suggest me something.

Thanks
Pallav

================================================== =================

#include<iostream.h>

template<typename T>
class B
{
public :

T DependentName;
int basefield;
typedef int X;
};


template<>
class B<char>
{

public :
enum E{basefield = 1};
int func()
{ return basefield;}
};


template<typename T>
class D:B<T>
{
public :
int func()
{ basefield = 12;
return basefield; }
};


void call(D<int> & obj_int){
cout<<"called function :: call(B<int> & obj_int) ::
"<<obj_int.func()<<endl;}

void call(D<char> & obj_char){
cout<<"called function :: call(B<char> & obj_char)::
"<<obj_char.func()<<endl;}


int main()
{

D<char> obj_char;
D<int> obj_int;

call(obj_char);
call(obj_int);

return 0;

}

  Réponse avec citation
 
Page generated in 0,04676 seconds with 9 queries