Article View: comp.std.c++
Article #4119Re: Is RTTI required if polymorphic constructor exists
From: Jason Merrill
Date: Fri, 19 Apr 1996 21:28
Date: Fri, 19 Apr 1996 21:28
27 lines
1625 bytes
1625 bytes
>>>>> Andrew Bell <abell@mindspring.com> writes:
> One problem, though, is that you may not care about the actual class
> of an object, but just whether it is derived from (or is) of a
> particular class, and RTTI doesn't help you there.
Why do you say that? That's precisely what dynamic_cast is for.
...
typedef class_where_method_is_introduced T;
if (T* p = dynamic_cast<T*>(generic_ptr))
{
p->method ();
}
...
Jason
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Technical Details
Message-ID:
<u9u3ygyp0i.fsf@yorick.cygnus.com>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageReferences:
<4kng7f$kt9@nuscc.nus.sg> <4l72i4$1js6@mule1.mindspring.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: jason@cygnus.com (Jason Merrill) Newsgroups: comp.std.c++ Subject: Re: Is RTTI required if polymorphic constructor exists Date: 19 Apr 1996 21:28:25 GMT Organization: Cygnus Support, Mountain View, CA Sender: jason@cygnus.com Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <u9u3ygyp0i.fsf@yorick.cygnus.com> References: <4kng7f$kt9@nuscc.nus.sg> <4l72i4$1js6@mule1.mindspring.com> NNTP-Posting-Host: taumet.eng.sun.com Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Nntp-Posting-Host: yorick.cygnus.com In-Reply-To: abell@mindspring.com's message of 19 Apr 1996 14:43:45 GMT X-Newsreader: Gnus v5.0 X-Lines: 20 Content-Length: 446 Originator: clamage@taumet