I will add one
Code:
class A
{
private:
int a;
public:
void func(void);
};
class B
{
private:
int a;
public:
virtual void func(void);
};
int main()
{
A a;
B b;
cout<<sizeof(a)<<" "<<sizeof(b)<<endl;
}
What will be the output of the above program and why?
Scroll down for an answer
2 4 because there is a Pointer to the virtual table to resolve the dynamic binding of the virtual function.