构造函数会自动调用基类的构造函数~~~
Code #include <stdio.h> #include <iostream> using namespace std;
class A { public: A() {cout<<"A构造"<<endl;} A(int i) {cout<<"A构造:i"<<endl;} ~A() { cout<<"A析构"<<endl;} }; class B :public A { public: B() { cout<<"B构造"<<endl;} B(int i):A(i) { cout<<"B构造"<<endl;} ~B() { cout<<"B析构"<<endl;}
};
int main() {
B b;
getchar(); return 0; }
输出什么呢?
|