[ create a new paste ] login | about

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

C++, pasted on Aug 22:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
struct Object {
   virtual void foo() {}
};

struct PhysicsObject : Object {};
struct Ball : PhysicsObject {};
struct SoftBall : Ball {
   virtual void foo() {
      cout << "SoftBall";
   }
};

int main() {
   SoftBall sb;
   Object* o = &sb;
   o->foo();
}


Output:
1
SoftBall


Create a new paste based on this one


Comments: