C++ how to move object to a nullptr
问题 I am thinking a strange use case where I want to move an object to a nullptr. Maybe I should give an code fragment: class Objpair { public: Objpair(Obj&& a, Obj&&b) : first(&a), second(&b) { } private: Obj* first; Obj* second; }; The problem is that when a and b is out of scope, the first and second pointer will be dangling. If I can move Object a onto the first pointer then there should be no problem of double free and scoping issues. If the member first were declared as Obj not Obj* pointer