Suppose I have two C++ classes:
class A
{
public:
A() { fn(); }
virtual void fn() { _n = 1; }
int getn() { return _n; }
protected:
int _n;
};
clas
One solution to your problem is using factory methods to create your object.
class Object { public: virtual void afterConstruction() {} // ... };
template< class C > C* factoryNew() { C* pObject = new C(); pObject->afterConstruction(); return pObject; }
class MyClass : public Object { public: virtual void afterConstruction() { // do something. } // ... }; MyClass* pMyObject = factoryNew();