Re: dynamic_cast problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/14/07, ganesh subramonian <gun_raj@xxxxxxxxx> 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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux