 <p>Before storing, cast the pointer with a <code>dynamic_cast&lt;void*&gt;</code> - this will give you a void pointer to the <em>most derived object</em>; this void pointer will, for the same objects, have the same address stored.</p> <p>See also <a href="http://stackoverflow.com/questions/8123776/are-there-practical-uses-for-dynamic-casting-to-void-pointer">this question</a>.</p>