private .
, , , :
class Interface;
class Concrete { public: .... private: Interface* m_interface; }
class ConcreteFoo: public Interface {};
: ConcreteBar. , , Pimpl Strategy, Concrete Factory, .
If you can't think of a second way to implement the heart, just encapsulate it in the class. Thus, if you later have to refactor, you just need to compose an abstract Interfaceusing the same set of methods, change several pointers (and the constructor), and everything will be fine with you;)
source
share