I have a base class, A, with an inquiry method bool isB(), and two derived classes, B and C, that inherit from A. I also have a container class, D, with a variable, x, and its respective accessor, x(). My problem, is that x needs to be a pointer to type B --or-- C, so that when I do something like D *test = new D();, then test->x() will either be a pointer to B or a pointer to C, which I won't know until run time and could then check using the inherited method, test->x()->isB(), which will be set within B and C's constructors to true or false, respectively.
So, my question is, what should the data type for x and return type for x() be? I was thinking like void *, but wasn't sure if that's correct or not.