fork(1) download
  1. #include <iostream>
  2.  
  3. class A
  4. {
  5. public:
  6. virtual void func(int a = 1)
  7. {
  8. std::cout << "class A::" << a << "\n";
  9. }
  10. };
  11.  
  12. class B : public A
  13. {
  14. public:
  15. virtual void func(int a = 2)
  16. {
  17. std::cout << "class B::" << a << "\n";
  18. }
  19. };
  20.  
  21. void func(A& a) { a.func(); }
  22.  
  23. int main()
  24. {
  25. B b;
  26. func(b);
  27. b.func();
  28.  
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0.02s 2724KB
stdin
Standard input is empty
stdout
class B::1
class B::2