小编Akh*_*aim的帖子

C++中移动赋值运算符的继承

我需要一些帮助来理解移动赋值运算符的继承过程。对于给定的基类

class Base
{
public:
    /* Constructors and other utilities */
    /* ... */

    /* Default move assignment operator: */
    Base &operator=(Base &&) = default;
    /* One can use this definition, as well: */
    Base &operator=(Base &&rhs) {std::move(rhs); return *this;}

    /* Data members in Base */
    /* ... */
};

class Derived : public Base
{
public:
    /* Constructors that include inheritance and other utilities */
    /* ... */

    Derived &operator=(Derived &&rhs);

    /* Additional data members in Derived */
    /* …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance move-assignment-operator

2
推荐指数
1
解决办法
2314
查看次数