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) 编辑 收藏