Order of constructor and destructor calling?
问题 I cannot understand the order of constructor and destructor calls? What will execute first in this statement A b=f(a)? Can someone please help me out? #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 " << endl << flush; a.SetX(100); return a; } int