🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by B. Dalton Wed, 17 Jan 1996 20:22
type_info
#3029
Author: B. Dalton
Date: Wed, 17 Jan 1996 20:22
31 lines
1498 bytes
The April draft says(see 
http://www.cygnus.com/misc/wp/draft/lib-support.html#lib.support
.rtti) about type_info::operator==

  bool operator==(const type_info& rhs) const;

  Effects:
    Compares the current object with rhs.
  Returns:
    true if the two values describe the same type.

What does "same" mean here? To be specific, say we had
...
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?

-- 
B. Dalton         DEC - Gaillimh
mailto:bdalton@xagony.ilo.dec.com
---
[ 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://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: type_info
#3036
Author: David Vandevoorde
Date: Thu, 18 Jan 1996 02:41
21 lines
1330 bytes
>>>>> "BD" == "B Dalton" <bdalton@xagony.ilo.dec.com> writes:
BD> class beatha{public:virtual ~beatha(){};}
BD> class duine:public beatha{};
BD> class gael: public duine {};

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

No, it doesn't since typeid(pd) = typeid(beatha*).
You probably meant `if(typeid(*pd)==typeid(duine)) ...',
but even then the answer is `no': typeid(*pd)==typeid(gael).

	Daveed
---
[ 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://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads