This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: dynamic_cast problem


On 11/14/07, ganesh subramonian <gun_raj@yahoo.com> wrote:
> hi
> i am afraid that i couldnt really understand what you
> have written. i am not a compiler writer.
> i would be grateful if you could explain why the
> problem occurs in simpler terms.
> thanks
> ganesh
>

I hope this isn't oversimplified or missing the point you're confused about.

The first rule in casting object pointers like that is the two objects
must be related, that is one must be a base class of the other or both
must be the same.

In your case, they both derive from the same class: A, but they do not
derive from each other.  The paragraph from the spec is explaining
specifically how the relationship is determined and tested and the
result of each.  Because your objects do not meet those criteria, a
NULL is returned upon failure.

Just because two objects might seem like they  have the same signature
(both deriving from the same class), they are not considered equal.

corey


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]