I have this structure:
class IIterator : public ICollectible{};
class A: public ICollectible{};
class b: public A{};
class c: public A{};
class d: public A{};
When I do something like this
IIterator* it = colection->getIterator();
whatType* db = dynamic_cast<whatType*>(it->hasCurrent());
colection is list with elements of type A
(it could have objects of type b
, c
or d
)
hasCurrent()
gives me something type ICollectible, so I have to do
dynamic cast so I can work
with b
, c
or d
, but how do I know which one it is?