| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
class A { public: virtual int getID(){return 0;} }; class B { public: virtual int getID(){return 1;} }; A *a = new A(); B *b = new B(); void *getA() { return a; } void *getB() { return b; } int main (int argc, char * const argv[]) { A *aa = static_cast<A *>(getA()); A *ba = static_cast<A *>(getB()); if(typeid(A) == typeid(*aa)) { cout << "aa IS A (" << typeid(*aa).name() << ")" << endl; } else { cout << "aa ISN'T A (" << typeid(*aa).name() << ")" << endl; } if(typeid(A) == typeid(*ba)) { cout << "ba IS A (" << typeid(*ba).name() << ")" << endl; } else { cout << "ba ISN'T A (" << typeid(*ba).name() << ")" << endl; } return 0; } works just as I expected: [Session started at 2008-07-13 22:33:04 -0400.] aa IS A (1A) ba ISN'T A (1B) On Jul 13, 2008, at 7:37 PM, Dmitry Markman wrote:
Dmitry Markman |
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/email@hidden This email sent to email@hidden
| References: | |
| >C++ question: dynamic_cast (From: Dmitry Markman <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.