class A
{
public:
A(){cout<<"a"<<endl;}
~A(){cout<<"del a"<<endl;}
A(const A&){cout<<"construct a"<<endl;}
};
const A f(A &h)
{
A b=h;
cout<<"haha"<<endl;
return b;
}
int main()
{
A c;
A d=f(c);
}
...全文
2616打赏收藏
请问构造函数执行了几次?
class A { public: A(){cout<<"a"<<endl;} ~A(){cout<<"del a"<<endl;} A(const A&){cout<<"construct a"<<endl;} }; const A f(A &h) { A b=h; cout<<"haha"<<endl; return b; } int main() { A c; A d=f(c); }