普通类的大小
#include<iostream>
using namespace std;
class Father
{
private:
int data;
public:
Father(int i):data(i){};
~Father();
public:
void show()
{
cout << "this is father class" << endl;
}
};
int main()
{
cout<<sizeof(Father)<<endl;
return 0;
}
/*
[root@Orz 18:36 ~]# run
4
[root@Orz 18:36 ~]#
*/
带virtual函数类的大小
#include<iostream>
using namespace std;
class Father
{
private:
int data;
public:
Father(int i):data(i){};
~Father();
public:
virtual void show()
{
cout << "this is father class" << endl;
}
};
int main()
{
cout<<sizeof(Father)<<endl;
return 0;
}
[root@Orz 18:36 ~]# run
16
[root@Orz 18:36 ~]#
?一下大了这么多,什么原因
|