// widget.h file class Widget { // still in header "widget.h" Widget(Widget&& rhs); // declarations Widget& operator=(Widget&& rhs); // only ____________________________________
Widget::~Widget() Widget(const Widget& rhs); // declarations Widget& operator=(const Widget& rhs); // only private: struct Impl; // declare implementation struct std::unique_ptr<Impl> pImpl; }; //widget.cpp file #include "Foo.h" // just include Foo.h in .cpp file. Widget::~Widget() = default; // as before Widget::Widget(Widget&& rhs) = default; // definitions Widget& Widget::operator=(Widget&& rhs) = default; Widget::Widget(const Widget& rhs) // copy ctor : pImpl(std::make_unique<Impl>(*rhs.pImpl)) {} Widget& Widget::operator=(const Widget& rhs) { *pImpl = *rhs.pImpl; return *this; }