C++ Add this pointer to a container by calling it in base class constructor
<pre><code>class Base
{
public:
Base (int a, int b);
private:
int a,b;
};

class Derived1
{
public:
Derived1():base(1,2){}
};
</code></pre>

<p>similarly Derived2, Derived 3 which doesnt contain any data members on its own</p>

<p>Now i need to contain these derived objects in a singleton, so i was thinking to call this in base constructor like</p>

<pre><code>Base::Base(int a, int b)
{
CBaseMgr::GetInstance()-&gt;AddtoVector(this);
}
</code></pre>

<p>so now if i construct </p>

<p>Derived d1, d2, d3 etc. will the Singleton's container contain all derived objects?</p>

<p>My doubt is can i do this adding of objects to container in base ctor or should i do in derived ctor.?</p>
