// GetMemory.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <stdlib.h> #include <string> class A { public: int _a; A() { _a=1; } void print() { printf("%d",_a); } }; class B:public A { public: int _a; B() { _a=2; } }; int main() { B b; b.print(); printf("%d ",b._a); return 0; } 运行结果是 1,2,您感到意外吗?