fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. class A
  5. {
  6. public:
  7. virtual void Bar()
  8. {
  9. std::cout << "A::Bar() -> " << this << std::endl;
  10. }
  11.  
  12. virtual void Foo()
  13. {
  14. std::cout << "A::Foo() -> " << this << std::endl;
  15. }
  16. };
  17.  
  18. class B
  19. {
  20. public:
  21. virtual void Foo()
  22. {
  23. std::cout << "B::Foo() -> " << this << std::endl;
  24. }
  25. };
  26.  
  27. int main()
  28. {
  29. B* b = reinterpret_cast<B*>( new A );
  30. b->Foo();
  31. return EXIT_SUCCESS;
  32. }
  33.  
Success #stdin #stdout 0.02s 2856KB
stdin
Standard input is empty
stdout
A::Bar() -> 0x9806008