fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. #include <typeinfo>
  4.  
  5. struct A
  6. {
  7. virtual ~A() {}
  8. std::string GetFunnyName() {return typeid(*this).name();}
  9. };
  10.  
  11. struct B: A {};
  12. struct C: A {};
  13.  
  14. int main()
  15. {
  16. A* o1 = new A;
  17. A* o2 = new B;
  18. A* o3 = new C;
  19. std::cout << o1->GetFunnyName() << '\n';
  20. std::cout << o2->GetFunnyName() << '\n';
  21. std::cout << o3->GetFunnyName() << '\n';
  22. }
  23.  
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
1A
1B
1C