Long time since the first problem..
This is a problem I've faced lately while developing in C# to have some statistics.
I've created a project that does something (of course !! :D) and created a number of classes with some inheritance tree, where some classes inherit from others, anyway, after that i needed to count the number of instances created from each class... pretty simple, just add a counter to the class, add increment/decrement methodology in the constructor/destructor. but. kind of... I'm lazy to open each class, add those members and add them to the newly created, not new!
So.. let's make use of Inheritances,
Create a base class "Countable Object" where all what you need is a private static dictionary which will hold all the type as a key, count as a value, with a constructor that increments the value of the type created.