There is a base class and a heir class. As you know, I can call the parent constructor by writing it in the initialization list of the constructor of the class - a successor:

class TestCopy1 { public: TestCopy1(const TestCopy1 & t){} }; class TestCopy2: public TestCopy1 { public: TestCopy2(const TestCopy2 & t):TestCopy1(t) {} }; 

Such a recording works great, and I achieve the desired functionality. But how to call the parent displacement constructor? Is it possible to? Or should it be completely redefined as a successor? Such a record does not work, the constructor is trying to call exactly the copy constructor, which is not defined:

 class TestMove1 { public: TestMove1(TestMove1 && t) {} }; class TestMove2 : public TestMove1 { public: TestMove2(TestMove2 && t) :TestMove1(t) {} }; 

    1 answer 1

    So tell the compiler what you want from it.

     TestMove2(TestMove2 && t) :TestMove1(std::move(t)) {} 
    • Thank you very much! - Range