All pastes #510889 Raw Edit

Mine

public cpp v1 · immutable
#510889 ·published 2007-05-26 03:48 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    }    void SomeDerv1SpecificMethod() {        //implementation    }};int main() {    Base* ptr; //I got this from somewhere, I want a Derv1 pointer so I can call SomeDerv1SpecificMethod    Derv1* dptr = (Derv1*)ptr->GetInterface("Derv1");    if(dptr == NULL) {        cout << "Umm... that wasn't actually a Derv1";        return 0;    }    dptr->SomeDerv1SpecificMethod();}