拷贝构造函数和赋值运算符

注意,下面几种情况都是调用拷贝构造函数

string st1(st);

string st1=st;

string st1=string(st)

string *pst=new string(st);

这种情况才会调用赋值运算符

 string s1 = "hello";
 string s2 = "world!";
 s1 = s2;
发布了154 篇原创文章 · 获赞 27 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/a13602955218/article/details/105335632