Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #9850
| Newsgroups | comp.lang.c++ |
|---|---|
| Subject | Re: dynamic_cast and generic pointer |
| References | <3d7f54db-fcbe-4f00-92c4-8d63c38d8cab@glegroupsg2000goo.googlegroups.com> |
| Date | 2011-09-07 01:08 +0200 |
| From | Asger-P <junk@asger-p.dk> |
| Organization | Asger-P |
| Message-ID | <op.v1es88gs2juju3@ajwin7> (permalink) |
Hi asit
On the: 06. of september-2011 At: 21:38 asit wrote:
> int main(int argc, char** argv)
> {
> B ob = new B;
> void *ptr;
> ptr = dynamic_cast<void*>(&ob);
> B* pt2 = dynamic_cast<B*>(ptr);
> return 0;
> }
That will not compile!
This is how dynamic_cast usually is used as far as I know.
int main(int argc, char** argv)
{
A *ob = new B;
B* pt2 = dynamic_cast<B*>(ob);
if( pt2 )
cout << "pt2 is of type B" << endl;
return 0;
}
Best regards
Asger-P
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
dynamic_cast and generic pointer asit <lipun4u@gmail.com> - 2011-09-06 12:38 -0700
Re: dynamic_cast and generic pointer Victor Bazarov <v.bazarov@comcast.invalid> - 2011-09-06 16:48 -0400
Re: dynamic_cast and generic pointer asit <lipun4u@gmail.com> - 2011-09-06 14:23 -0700
Re: dynamic_cast and generic pointer Ian Collins <ian-news@hotmail.com> - 2011-09-07 10:09 +1200
Re: dynamic_cast and generic pointer "Default User" <defaultuserbr@yahoo.com> - 2011-09-06 18:07 -0500
Re: dynamic_cast and generic pointer Joe Greer <jgreer@doubletake.com> - 2011-09-08 14:45 +0000
Re: dynamic_cast and generic pointer Asger-P <junk@asger-p.dk> - 2011-09-07 01:08 +0200
Re: dynamic_cast and generic pointer Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-07 00:02 -0500
Re: dynamic_cast and generic pointer Juha Nieminen <nospam@thanks.invalid> - 2011-09-07 06:22 +0000
Re: dynamic_cast and generic pointer Goran <goran.pusic@gmail.com> - 2011-09-07 04:16 -0700
Re: dynamic_cast and generic pointer BGB <cr88192@hotmail.com> - 2011-09-08 23:17 -0700
csiph-web