relation between typeid and typeinfo class (related by friend ?)

G

Ganesh

Hi,

typeinfo class has a private constructor and only typeid can return
object to typeinfo class. So here I am wondering how these two are
related. Are these two related through 'friend' so that typeid can
access private methods of typeinfo class.

Can some one list me the exact declaration of typeid and typeinfo class
if they have right away ?

Thanks
Ganesh
 
K

Karl Heinz Buchegger

Ganesh said:
Hi,

typeinfo class has a private constructor and only typeid can return
object to typeinfo class. So here I am wondering how these two are
related. Are these two related through 'friend' so that typeid can
access private methods of typeinfo class.

Not in my system.
The important point is: What may be forbidden for you (the programmer)
is not necessarily forbidden for the compiler. The compiler may do
things (such as creating a type_info object although the constructor
is private) which a programmer can't do.
Can some one list me the exact declaration of typeid and typeinfo class
if they have right away ?

You already have them.
In order to use a type_info object, you need to include some header file.
This file contains the declaration.
 
B

ben

Can some one list me the exact declaration of typeid and typeinfo class
if they have right away ?

typeid is NOT a function but an operator believe it or not, so it doesn't
have a declaration. You can either pass in a class or an object for typeid
to return a typeinfo object.

ben
 
R

Rolf Magnus

Ganesh said:
Hi,

typeinfo class has a private constructor and only typeid can return
object to typeinfo class. So here I am wondering how these two are
related. Are these two related through 'friend' so that typeid can
access private methods of typeinfo class.

typeid is not a function. It is an operator built into the compiler.
Can some one list me the exact declaration of typeid and typeinfo class
if they have right away ?

typeinfo might have one. To find it out, look into the header. typeid
doesn't have any declaration.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top