All pastes #505740 Raw Edit

Unnamed

public cpp v1 · immutable
·published 2007-05-23 18:36 UTC
rendered paste body
//abstract Foo base classclass Foo {public:    virtual int getValue()=0;    virtual void setValue(int num)=0;};//specific implementation of Foo functionalityclass MyFoo : public Foo {private:    int* value;public:    Foo() {        value=new int;        *value=0;    }    ~Foo() {        delete value;    }    virtual int getValue() {        return *value;    }    virtual void setValue(int num) {        *value = num;    }};//the following function can take a pointer to a MyFoo or to any other class//derived from Foo (even indirectly; like one derived from MyFoo!)void setFourtyTwo(Foo* obj) {    obj.setValue(42);};