c++ 复制与赋值
#include <iostream>
#include <string>
using namespace std;
class A
{
public:
int member;
A(int val):member(val){
}
A(const A& a):member(a.member)
{
cout << "()" << endl;
}
A& operator= (const A& a)
{
cout << "=" << endl;
}
};
int main()
{
A b(0);
A a = A(b);
}
为什么 输出 () 调用copy constructor