[lug] typeid calls in g++ 2.95.2

Scott A. Herod herod at interact-tv.com
Tue Nov 7 16:17:07 MST 2000

"D. Stimits" wrote:
> >
> > Yes, but obviously it is known at runtime what type the object
> > labeled "a" truly is so that polymorphism will work correctly.
> >
> > It was my understanding that typeid should be able to determine
> > that type as well.  That is the reason that typeid only works
> > on polymorphic classes.
> This is correct...so were the results. Something very subtle is that you
> were asking for the typeid of the pointer...not the dereferenced object
> that it points TO. Change typeid( a ).name() to become the dereferenced
> typeid( *a ).name().

Ahhhh.  I see.  Very good.

Thank you very much.  Beer's on me.


More information about the LUG mailing list