🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3208

Re: typeinfo

#3208
From: steven2
Date: Fri, 02 Feb 1996 15:49
29 lines
1327 bytes
John Max Skaller <maxtal@suphys.physics.su.oz.au> wrote:

>> class beatha{public:virtual ~beatha(){};}
>> class duine:public beatha{};
>> class gael: public duine {};
>> 
>> beatha *pd=new gael;
>> if(typeid(pd)==typeid(duine)
>> {       cout<<"duine";
>> }
>> ...
>> does "duine" get printed here or not?

>No. pd denotes an object of exact type "gael".

I believe typeid (pd) is typeid (betha*). What I think you wanted is

if (typeid (*pd) == typeid (duine))

and so (typeid (*pd) == typeid (gael)) will evaluate to true.

Steve



[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy is
  summarized in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
]
Technical Details
Message-ID: <4es3ur$4ha@post.acadia.net>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
References: <310B7660.4116@suphys.physics.su.oz.au>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
From: steven2@salesbk.com
Newsgroups: comp.std.c++
Subject: Re: typeinfo
Date: 2 Feb 1996 15:49:01 GMT
Organization: DownEast Technology Inc.
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <4es3ur$4ha@post.acadia.net>
References: <310B7660.4116@suphys.physics.su.oz.au>
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Nntp-Posting-Host: blf6.acadia.net
X-Newsreader: Forte Free Agent 1.0.82
Content-Length: 534
X-Lines: 24
Originator: clamage@taumet