Created
March 31, 2018 01:30
-
-
Save phg1024/b509bc85291fd47468ebf4e8c8b43715 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <typeinfo> | |
#include <stdexcept> | |
using namespace std; | |
class A { | |
public: | |
virtual void print() { cout << "A" << endl; } | |
}; | |
class B : public A { | |
public: | |
virtual void print() { cout << "B" << endl; } | |
}; | |
class C : public A { | |
public: | |
virtual void print() { cout << "C" << endl; } | |
}; | |
class MyE : public exception { | |
}; | |
int main() { | |
const A& b = B(); | |
const A& c = C(); | |
cout << typeid(b).name() << endl; | |
cout << typeid(c).name() << endl; | |
cout << typeid(MyE()).name() << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment