Quote:
Originally Posted by raconteur
Doesn't anybody use unions any more? I'm starting to feel a bit like a dinosaur here...
Back on topic: IMO, void pointers are quite useful in the right conditions. I agree that they need to be used only where necessary, and not as a catch-all convenience but I have several classes where their polymorphic properties would not be possible without void pointers. Bad practice? I think not, just another tool.
|
Union was my initial thought, and I rejected it.
The point is that union would allocate one memory area/location for the structures/pointer to them, and in such a case the need to differentiate between the two entities still remains, i.e. a, say, flag is needed.
So I decided to use two pointers per two type possibilities, and the fact that NULL pointer means unused pointer.