随笔-77  评论-5  文章-2  trackbacks-0
class Square{
public:
 Square(int x ) :value(x*x){
 }

Square(const Square& other) = delete;//rule 1

const Square & operator = (const Square& other) == delete;//rule 2
const Square & operator = (Square&& other) = delete;//rule3 

..
}

Square s = 9; //因为s没有初始化,会先用9 调用构造函数 Square(int x ) , 然后调用Square(const Square& other),和rule1 违背
Square s2(8);
 s= s2;//对应rule 2
 s= Square(9);//对应 rule3 
posted on 2019-12-31 21:11 huohuo 阅读(1052) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: