fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A {
  5. public:
  6. A() { foo(); }
  7. virtual void foo() { cout << 1; }
  8. };
  9.  
  10. class B : public A {
  11. public:
  12. B() : A() {
  13. }
  14.  
  15. void foo() override { cout << 2; }
  16. };
  17.  
  18. int main() {
  19. // your code goes here
  20. B b;
  21. return 0;
  22. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
1