 <p>Since you can't refactor as suggested, you should check what type you need to return based on the <code>type</code> member that you assign in the <code>init()</code> function. I assume this will work, but you haven't shown where <code>type</code> is defined:</p> <pre><code>const void* Investment::getItem() const { switch(type) { case BUILDING_TYPE: case UNIT_TYPE: return &amp;unitType; case UPGRADE_TYPE: return &amp;upgradeType; case TECH_TYPE: return &amp;techType; } return NULL; } </code></pre> <p>Doing this however, means that the caller of <code>getItem()</code> has to be able to perform the appropriate downcast. Given that you don't provide this explicitly, this is going to be a constant source of confusion of users of your code.</p> <h1>However:</h1> <p>If you are passing around <code>void*</code> and expecting users of your class to downcast to the correct type, this is almost always an indication of bad design in <code>C++</code>. The correct approach would be to refactor this into a proper polymorphic class hierarchy as suggested by @juanchopanza in his answer.</p>