Hi, I am trying to create a function that compare's two objects.
Here, take a look:
The error I get when I try to compile is at this statement:Code:int Integer::compareTo(const NodeItem &anotherNodeItem) { int returnCode = 0; Integer *otherInteger = dynamic_cast<Integer&>(anotherNodeItem); if (otherInteger == NULL) returnCode = ERROR_INCOMPATIBLE_TYPES; else returnCode = compareTo(*otherInteger); delete otherInteger; return returnCode; }
The error is this:Code:Integer *otherInteger = dynamic_cast<Integer&>(anotherNodeItem);
Integer.cpp(54): error C2682: cannot use dynamic_cast to convert from 'const NodeItem' to 'Integer &'
I'm not too sure of another way of doing this, but basically I want the function to be able to take a NodeItem pointer, and check whether the NodeItem is an Integer by using dynamic_cast and testing for a NULL result.
Thanks for the help in advance.




Reply With Quote