Guest User

what

a guest
Feb 19th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2. class B
  3. {
  4. public:
  5.     int x;
  6.     B(int v = 0) : x(v) {}
  7.     virtual void f(int a = 1, int b = 2) {printf("\n%d", a);}
  8. };
  9.  
  10. class D : public B
  11. {
  12.     public:
  13.     D(int v) : B(v) {}
  14.     void f(int a = 3, int b = 4) {printf("\n%d", a);}
  15. };
  16.  
  17. int main()
  18. {
  19.     B b, *pb;
  20.     D d(15);
  21.     pb = &d;
  22.     pb->f(10,20);
  23.     b.f();
  24.     pb->f();
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment