关于此题:
class
A
{
public
:
int
_a;
A()
{
_a = 1;
}
void
print()
{
printf
(
"%d"
,_a);
}
};
class
B:
public
A
{
public
:
int
_a;
B()
{
_a = 2;
}
};
void
main(
int
argc,
char
*argv[])
{
B b;
b.print();
printf
(
"%d"
,b._a);
解答参考:
http://bbs.csdn.net/topics/370194628