当我们删除(//)B的Copy构造函数时,我们转到A的Copy构造函数,当我们也删除(//)A的Copy构造函数时,它会忽略“ B object2 = object1”,并且不会引发编译错误。谁能解释为什么?
#include <iostream>
using namespace std;
#include <iostream>
using namespace std;
class A {
public:
A() { cout << "A(0)" << endl; }
A(const A& a) { cout << "A(1)" << endl; }
};
class B {
public:
B() : a() { cout << "B(0)" << endl; }
B(const B& b) { cout << "B(1)" << endl; }
private:
A a;
};
int main() {
B object1;
B object2 (object1);
return 0;
}