注意,下面几种情况都是调用拷贝构造函数
string st1(st);
string st1=st;
string st1=string(st)
string *pst=new string(st);
这种情况才会调用赋值运算符
string s1 = "hello";
string s2 = "world!";
s1 = s2;
注意,下面几种情况都是调用拷贝构造函数
string st1(st);
string st1=st;
string st1=string(st)
string *pst=new string(st);
这种情况才会调用赋值运算符
string s1 = "hello";
string s2 = "world!";
s1 = s2;