fork download
  1. #include <iostream>
  2. using namespace std;
  3. class A{
  4. public:
  5. virtual void func(int val=1){
  6. cout << "func A\n";
  7. }
  8. virtual void test(){func();}
  9. };
  10. class B:public A{
  11. public:
  12. void func(int val=0){cout << "func B\n";}
  13.  
  14. };
  15. int main() {
  16. // your code goes here
  17. B *p = new B;
  18. p->test();
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
func B