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 調(diào)用構(gòu)造函數(shù)
Square(int x ) , 然后調(diào)用Square(const Square& other),和rule1 違背Square s2(8);
s= s2;//對應(yīng)rule 2
s= Square(9);//對應(yīng) rule3
posted on 2019-12-31 21:11
huohuo 閱讀(1065)
評論(0) 編輯 收藏