不錯的派生類調用基類構造函數
#include<iostream>
using namespace std;
class BASE{
public:
/*****************found1*****************/
int i;
BASE(int i){cout<<"調用基類BASE的構造函數:"<<i<<endl;}
~BASE(){cout<<"調用基類BASE的析構函數"<<endl;}
};
class A: public BASE
{
public:
/*****************found2*****************/
A(int a,int b):BASE(a),b(b){ cout<<"調用派生類A的構造函數:"<<a+b<<endl;}
~A(){cout<<"調用派生類A的析構函數"<<endl;}
private:
BASE b;
};
int main(){
/*****************found3*****************/
A obj(1,2);
}