All pastes #510891 Raw Edit

Untitled

public cpp v1 · immutable
#510891 ·published 2007-05-26 03:50 UTC
rendered paste body
class Base {    virtual Base* GetInterface(string type_I_want)=0;    virtual void SomeBaseMethod()=0;};class Derv1: public Base {    virtual Base* GetInterface(string  type_I_want) {        if(type_I_want == "Derv1") {            return this;        } else {            return NULL;        }    }    virtual void SomeBaseMethod() {        //implementation    }    virtual void SomeDerv1SpecificMethod() {        //implementation    }};class Derv2: public Base {    virtual Base* GetInterface(string  type_I_want) {        if(type_I_want == "Derv2") {            return this;        } else {            return NULL;        }    }    virtual void SomeBaseMethod() {        //implementation    }    virtual void SomeDerv2SpecificMethod() {        //implementation    }};class DervFoo: public Derv1 {    virtual Base* GetInterface(string  type_I_want) {        if(type_I_want == "DervFoo") {            return this;        } else if(type_I_want == "Derv1") { //if he asks for a Derv1, he can have it too!            return this;        } else {            return NULL;        }    }    //we may want to override this, or maybe not    virtual void SomeBaseMethod() {        //implementation    }    //we may want to override this, or maybe not    //virtual void SomeDerv1SpecificMethod();    void SomeDervFooSpecificMethod() {        //implementation    }};