派生出来的类如何调用父类的带参数的构造函数
程序代码:
CBase::CBase() { cout<<"CBase()"<<"\n"; } CBase::~CBase() { cout<<"~CBase()"<<"\n"; } CBase::CBase(int a) { A = a; cout<<"CBase(int a)"<<"\n"; // return; } CA::CA() { cout<<"CA()"<<"\n"; } CA::~CA() { cout<<"~CA()"<<"\n"; } CA::CA(int a) { cout<<"CA(int a)"<<"\n"; CBase::CBase(a); }如果在这红色的地方直接调用父类的构造函数,测试结果:
CBase()
CA(int a)
CBase(int a)
~CBase() //怎样可以避免这里被析构?