fork download
  1. #include <iostream>
  2. #include <typeinfo>
  3. using namespace std;
  4. #define self this
  5. class Base
  6. {
  7. private:
  8. void base_foo() {cout << "base foo" << endl;}
  9. protected:
  10. void base_bar() {cout << "base bar" << endl;}
  11. public:
  12. Base()
  13. {
  14. if(string(typeid(*self).name()) == string("4Base"))
  15. base_foo();
  16. base_bar();
  17. }
  18. };
  19. class Derived
  20. : public Base
  21. {
  22. public:
  23. Derived()
  24. : Base()
  25. {
  26. cout << "Derived created" << endl;
  27. }
  28. };
  29.  
  30. int main() {
  31. Derived derived;
  32. return 0;
  33. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
base foo
base bar
Derived created