On 11/05/2014 09:17 AM, Patrick Jeeves wrote:

> class foo
> {
> static std::list<foo*> foo_list;
> typedef std::list<foo*>::iterator iterator;
> public:
>      foo()
>      {
>         foo_list.push_back(this);
>      }
>      ~foo()
>      {
>         foo_list.remove(this);
>      }

Going completely off-topic, I recommend against objects registering themselves that way. That idiom has caused trouble in more than one project for us.

In general, I think a constructor should not have side-effects unless needed for the object's construction (e.g. allocating a resource for the object should obviously fine).

Ali

Reply via email to