思考
如下有2个类,A
和B
。我们在B类中声明了两个A
类:_a1
和_a2
。
class A
class A {
public:
A(int a, int b, int c) {
cout << "A(int a, int b, int c)" << endl;
}
~A(){
cout<<"~A()"<<endl;
}
private:
int _a;
int _b;
int _c;
};
class B
class B {
public :
B() : _a1(1, 2, 3), _a2(1, 4, 9) {
cout << "B()" << endl;
}
~B() {
cout << "~B()" << endl;
}
private:
A _a1;
A _a2;
};
标签:总结,函数,int,public,a1,a2,和析构,class
From: https://www.cnblogs.com/cloucodeforfun/p/17056934.html