如果是在产生对象的时候初始化可以通过派生类的构造函数。
class A{public: int a; A(int a1):a(a1){}};class B:public A{public: int b; B(int a1, int b1) :b(b1), A(a1){}};