![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
基础
叶余德
哈哈 工作了
展开
-
何时调用构造函数
在使用x、y坐标时,将两个矢童相加将非常简单,只要将两分量相加,得到最终的x分量;将两个y分量相加,得到最终的y分量即可。根据这种描述,可能使用下面的代码: Vector Vector::operator+(const Vector & b)const { vector sum; sum.x=x+b.x; sum.y=y+b.y; return sum;翻译 2016-08-30 17:18:24 · 2798 阅读 · 0 评论 -
复制构造函数可能出现的问题
1.不增加计数器nmn_strings的值 需要更新的显式复制构造函数 StringBad::StringBad( const String & s) { num_strings++; ... // important stuff to go here } 2. 字符串内容出现乱码 sailor.str=sport.str;翻译 2016-08-30 17:36:54 · 365 阅读 · 0 评论