Topic: Some questions regarding RTTI
Author: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: Thu, 10 Mar 1994 17:51:53 GMT Raw View
damian@cs.monash.edu.au (Damian Conway) writes:
>Some questions that the ANSI/ISO Resolutions don't _seem_ to answer:
>
>------------------
>1. Is the typeid() expression:
>
> class Class {};
> ...
> typeid(Class)
>
> a compile-time expression?
What do you mean by a compile-time expression?
It's not a ``constant-expression'' [ARM 5.19], since it's not an integer.
The notion "compile-time expression" isn't defined by the language.
However, most implementations will fully evaluate this expression
at compile-time (or more likely at link-time), if that's what you mean.
>------------------
>2. What is the value of der_ptr after:
>
> class Base {};
> class Der: public Base {};
> class MoreDer: public Der {};
>
> Base * base_ptr = new MoreDer;
> Der * der_ptr = dynamic_cast<Der*> (base_ptr);
`dpr_ptr' now points to the `Der' subobject of the `MoreDer' object allocated
by the expression `new MoreDer'.
--
Fergus Henderson - fjh@munta.cs.mu.oz.au