[ create a new paste ] login | about

Link: http://codepad.org/Lbp8g9XM    [ raw code | output | fork ]

mickey24 - C++, pasted on Jan 1:
#include <iostream>
using namespace std;

class Base {
public:
  ~Base() {}
  virtual void f(int i = 10) {
    cout << "Base::f    : " << i << endl;
  }
};

class Derived : public Base {
public:
  Derived() {}
  void f(int i = 20) {
    cout << "Derived::f : " << i << endl;
  }
};

int main(int argc, char const* argv[]) {
  Base b;
  Derived d;
  Base* pb = new Derived;

  b.f();
  d.f();
  pb->f();

  delete pb; 
  return 0;
}


Output:
1
2
3
Base::f    : 10
Derived::f : 20
Derived::f : 10


Create a new paste based on this one


Comments: