[ create a new paste ] login | about

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

sehe - C++, pasted on Aug 22:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>

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


int main()
{
    Object* o = new SoftBall;

    o->foo();

    delete o;

    return 0;
}


Output:
1
SoftBall::foo();


Create a new paste based on this one


Comments: