Why does the insertion of user defined destructor require an user defined copy constructor
问题 The following code compiles: #include <vector> #include <iostream> #include <memory> using namespace std; class container { public: container(){} ~container(){} }; class Ship { public: Ship(){} //Ship(const Ship & other){cout<<"COPY"<<endl;} //~Ship(){} std::unique_ptr<container> up; }; Ship buildShip() { Ship tmp; return tmp; } int main(int argc, char *argv[]) { return 0; } But if we include the user defined destructor ~Ship(){} , the code will only compile if we also include the user