Re: Lets put it another way
"Joshua Maurice" <joshuamaurice@gmail.com> wrote in message
news:67b00b83-a90a-4dda-b1ae-3a6c1303f7fc@x38g2000pri.googlegroups.com...
On May 25, 2:39 pm, "Paul" <pchris...@yahoo.co.uk> wrote:
typeid does not require an object but when it is passed an object it gives
us the type of that object.
Only if the static type of the expression is polymorphic. Ex:
int x;
typeid(x);
will say int.
int x;
char* c = reinterpret_cast<char*>(&x);
typeid(*c);
is not UB, and will say char.
struct A { virtual ~A() {} };
A a;
char* c = reinterpret_cast<char*>(&a);
typeid(*c);
is not UB, and will say char.
struct A { virtual ~A() {} };
C c;
A* a = reinterpret_cast<A*>(&c);
typeid(*a);
is UB and may/will crash horribly.
--------------------------------------------------------------
Yes all this is known but we are diverting off the subject, this has nothing
to do with this non modifiable object of array type than Ian is suggesting
doesn't exist.
He may be correct in the case I put forward as I didn't create an non
modifiable object of array type. This is the debate , not what typeid does
or does not do.