D
Dan Noland
- Hello All -
I believe that I have a firm understading of dynamic_cast and its
proper usage, however g++-2.95.4 is telling me that something I believe to
be possible is not possible.
I have:
class ObjectRefList: /*extends*/ public Object {
/* ObjectRefList Stuff Lives Here */
public:
class ObjectRefListIterator: /*extends*/ public Object {
ObjectRefListIterator& operator++();
bool operator==(ObjectRefList& aOp) const;
bool operator!=(ObjectRefList& aOp) const;
Object& getCurrent() const;
}
}
Each of my Interfaces has an ObjectRefList called mListeners. So I tried
something like:
bool FooInterface:nClick()
{
ObjectRefList::ObjectRefListIterator i = mListeners.begin();
for(;i != mListeners.end(); i++)
{
dynamic_cast<FooInterface&>(i.getCurrent()).onClick();
}
}
However g++ tells me:
FooInterface.cpp:41: cannot dynamic_cast
`+i.ZObjectRefList::ZObjectRefListIterator::getCurrent()' (of type `class
Object &') to type `class FooInterface &'
I was under the impression that dynamic_cast
(1) worked on references and
(2) allowed downcasts (when appropriate)
Please disabuse me of these notions if either of them are untrue.
Otherwise is this just a g++ issue or am I doing something retarded?
YT,
Dan Noland
Purdue RCS Programmer/Analyst
I believe that I have a firm understading of dynamic_cast and its
proper usage, however g++-2.95.4 is telling me that something I believe to
be possible is not possible.
I have:
class ObjectRefList: /*extends*/ public Object {
/* ObjectRefList Stuff Lives Here */
public:
class ObjectRefListIterator: /*extends*/ public Object {
ObjectRefListIterator& operator++();
bool operator==(ObjectRefList& aOp) const;
bool operator!=(ObjectRefList& aOp) const;
Object& getCurrent() const;
}
}
Each of my Interfaces has an ObjectRefList called mListeners. So I tried
something like:
bool FooInterface:nClick()
{
ObjectRefList::ObjectRefListIterator i = mListeners.begin();
for(;i != mListeners.end(); i++)
{
dynamic_cast<FooInterface&>(i.getCurrent()).onClick();
}
}
However g++ tells me:
FooInterface.cpp:41: cannot dynamic_cast
`+i.ZObjectRefList::ZObjectRefListIterator::getCurrent()' (of type `class
Object &') to type `class FooInterface &'
I was under the impression that dynamic_cast
(1) worked on references and
(2) allowed downcasts (when appropriate)
Please disabuse me of these notions if either of them are untrue.
Otherwise is this just a g++ issue or am I doing something retarded?
YT,
Dan Noland
Purdue RCS Programmer/Analyst