public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de> To: john.allen@iona.com Cc: egcs-bugs@cygnus.com Subject: Re: Dynamic casting does not appear to be working at all Date: Wed, 09 Sep 1998 03:45:00 -0000 [thread overview] Message-ID: <199809090720.JAA02162@mira.isdn.cs.tu-berlin.de> (raw) In-Reply-To: <35F4F7E1.C91AF825@iona.com> > A dynamic_cast<> from a base class to a derived class produces a compile > time error. Which compiler version? Which source code? On egcs 2.92.02, the program below compiles fine. Please note that you cannot dynamic_cast objects, you need to use pointers or similar. struct A{ virtual ~A(); }; struct B:A{ }; A::~A(){} int main() { A *a = new A; B *b = dynamic_cast<B*>(a); } > Also calling a method via a member pointer which is typedef'd as > taking a base class reference to A, but is in reality expecting a > derived class references to B, but is passed a derived class > reference to C, which is then dynamic_cast<B> works where it should > fail. I was not able to translate this description into C++. Can you give an example as well? Regards, Martin
prev parent reply other threads:[~1998-09-09 3:45 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 1998-09-08 2:22 John Allen 1998-09-09 3:45 ` Martin von Loewis [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=199809090720.JAA02162@mira.isdn.cs.tu-berlin.de \ --to=martin@mira.isdn.cs.tu-berlin.de \ --cc=egcs-bugs@cygnus.com \ --cc=john.allen@iona.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).