Surely, with what you have, casting wont work the way you
have proposed here. But what you can do is to write all the
conversion/traversal logic in a member function or an operator
overload in one of these collection classes or in a common function
which does the conversion whenever its needed.
I would add though, that there are better ways of implementing
collections. You could have based these collection classes on
collection and enumeration interfaces, which makes traversal
easy. It would have also helped you in keeping the things cleaner
and casting issues would be much easier to manage as the collection
would all have a common base.
Regards
Ankur
|