#include <stdio.h>
struct people
{
int d;
int f;
short g;
};
//以下代码段中,参数指针student* aaa改为引用student& aaa
class student : public people
{
public:
int a;
int b;
int c;
int init(student& aaa);
int print(student* bbb);
};
int student :: init(student& aaa)
{
printf("%d\n",sizeof(student));
aaa.a=0x1;
aaa.b=0x2;
this->d='A';
aaa.people::d='A';
aaa.people::f=0x3;
aaa.people::g=0x4;
return 0;
}
int student :: print(student* bbb)
{
printf("%x %x %x\n",bbb->a,bbb->b,bbb->d);
printf("%d\n",bbb->f);
printf("%d\n",bbb->g);
return 0;
}
int main( )
{
student aaa;
student bbb;
aaa.init(bbb);
aaa.print(&bbb);
return 0;
}