说一堂课
class Piece {} ;
如果我是正确的,那应该相当于:
class Piece {
   //C++ 03
    Piece ();                          //default constructor
    Piece( const Piece&);              //copy constructor
    Piece& operator=(const Piece&);    //copy assignment operator
    ~Piece();                          //destructor
    //Since C++ 11
    Piece(Piece&&);                   //move constructor
    Piece& operator=(Piece&&);        //move assignment operator
};
那么我能对这些说些什么呢?
一个)
class Pawn{
    ~Pawn() {}// Only destructor
};
b)
class Bishop{
    Bishop(Bishop&& ) {}// Only move constructor
};
C)
class Knight{
    Knight(Knight&&, int =0) {} // move constructor, when no second arg present
};
d)
class Rook {
    Rook(const Rook& ) {}// Only copy constructor
};
e)
class King{
        King& operator=(const King&) = delete;
    };
我根据我的理解编译器将生成:
- a)默认构造函数,复制构造函数,复制赋值运算符,(移动构造函数/赋值运算符?)
- b) 析构函数
- c) 析构函数
- d) 复制赋值运算符和析构函数(移动构造函数/赋值运算符?)
- e)默认构造函数,复制构造函数,析构函数,(移动构造函数/赋值运算符?)
我在这里是正确的还是遗漏了什么?
C++11当用户没有提供时,基本上是否有任何新的生成函数规则?