为什么这个程序中sizeof的结果是4?请高手指教
为什么这个程序中sizeof的结果是4?请高手指教#include<iostream>
#include<complex>
using namespace std;
class base
{
public:
base(){cout<<"base-ctor"<<endl;}
~base(){cout<<"base-dtor"<<endl;}
virtual void f(int){cout<<"base::f(int)"<<endl;}
virtual void f(double){cout<<"base::f(double)"<<endl;}
virtual void g(int i=10){cout<<"base::g()"<<i<<endl;}
void g2(int i=10){cout<<"base::g2"<<i<<endl;}
};
class derived:public base
{
public:
derived(){cout<<"derived-ctor"<<endl;}
~derived(){cout<<"derived-dtor"<<endl;}
void f(complex<double>){cout<<"derived::f(complex)"<<endl;}
virtual void g(int i=20){cout<<"derived::g()"<<i<<endl;}
};
void main()
{
base b;
derived d;
base *pb=new derived;
cout<<sizeof(base)<<"tt"<<endl;
cout<<sizeof(derived)<<"bb"<<endl;
}