fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class A {
  6. public:
  7. A() {};
  8. virtual void say() {
  9. cout << "A" << endl;
  10. }
  11. };
  12.  
  13. class B : public A {
  14. public:
  15. B() : A() {};
  16. virtual void say() {
  17. cout << "B" << endl;
  18. }
  19. };
  20.  
  21. int main() {
  22. A* a = new A();
  23. A* b = new B();
  24. a->say();
  25. b->say();
  26. return 0;
  27. }
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
A
B