K
kish_nand
Could someone please explain me the concept behind virtual functions
and vtables. I am little confused about this. Please refer to the
following code and tell me how many virtual tables would be created and
what they would contain:
class base
{
virtual void display()
{
cout<<"base display"<<endl;
}
void disp()
{
cout<<"base disp"<<endl;
}
};
class d1: public base
{
void display()
{
cout<<"d1 display"<<endl;
}
};
class d2: public base
{
void display()
{
cout<<"d2 display"<<endl;
}
};
void main()
{
base *b = new d1;
d1->display();
}
Thanking you,
regards
Nand Kishore
and vtables. I am little confused about this. Please refer to the
following code and tell me how many virtual tables would be created and
what they would contain:
class base
{
virtual void display()
{
cout<<"base display"<<endl;
}
void disp()
{
cout<<"base disp"<<endl;
}
};
class d1: public base
{
void display()
{
cout<<"d1 display"<<endl;
}
};
class d2: public base
{
void display()
{
cout<<"d2 display"<<endl;
}
};
void main()
{
base *b = new d1;
d1->display();
}
Thanking you,
regards
Nand Kishore