This is an interview question: how can we store the objects of let's say 3 different classes which are totally independent of each other.
My answer was: create an array which stores all void pointers. like :
void *array[];
and store the pointers of all the objects.the array elements can be many.
but for retrieving the elements,i said we can use the dynamic cast or the static cast!
this i think is the wrong answer.i think dynamic cast and static cast are supposed to be used among the classes which are dependent.
please correct me if i am wrong.
if dynamic cast and static cast doesn't work.May be we can use reinterpret cast.
but is this the correct way to do this task?
boost::any.class. C does have user-defined types in general, though (see:struct) and thus this question would be applicable to both languages... if it weren't for the{dynamic,static,reinterpret}_castreferences.