我无法理解构造函数和析构函数调用的顺序?什么将在本声明中首先执行A b = f(a)?有人可以帮帮我吗?
#include<iostream>
using namespace std;
class A {
int x;
public:
A(int val = 0)
:x(val) {
cout << "A " << x << endl << flush;
}
A(const A& a) {
x = a.x;
cout << "B " << x << endl << flush;
}
void SetX(int x) {
this->x = x;
}
~A() {
cout << "D " << x << endl << flush;
}
};
A f(A a) {
cout << " C " …Run Code Online (Sandbox Code Playgroud)