[ create a new paste ] login | about

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

k06a - C++, pasted on Apr 16:
////////////////////////////////

class A
{
public:
    virtual ~A() {}
    virtual void funcA1() = 0;
    virtual void funcA2() = 0;
};

////////////////////////////////

class B
{
public:
    virtual ~B() {}
    virtual void funcB1() = 0;
    virtual void funcB2() = 0;
    virtual void funcB3() = 0;
};

////////////////////////////////

class C
{
public:
    virtual ~C() {}
    virtual void funcC1() = 0;
    virtual void funcC2() = 0;
    virtual void funcC3() = 0;
};

////////////////////////////////

class ISuper
{
public:
    virtual ~ISuper() {}
    virtual A * interfaceA() = 0;
    virtual B * interfaceB() = 0;
    virtual C * interfaceC() = 0;
};

////////////////////////////////

class AbstractSuper
    : public ISuper
{
public:
    virtual ~AbstractSuper() {}
    virtual A * interfaceA() { return 0; }
    virtual B * interfaceB() { return 0; }
    virtual C * interfaceC() { return 0; }
};

////////////////////////////////

class FirstSuper
    : public AbstractSuper
    , public A
    , public B
{
public:
    virtual ~FirstSuper() {}

    virtual A * interfaceA()
    {
        return this;
    }
    virtual B * interfaceB()
    {
        return this;
    }

    virtual void funcA1() {}
    virtual void funcA2() {}

    virtual void funcB1() {}
    virtual void funcB2() {}
    virtual void funcB3() {}
};

////////////////////////////////

int main(int argc, char * argv[])
{
    ISuper * super = new FirstSuper;
    super->interfaceA()->funcA1();
    super->interfaceA()->funcA2();
    super->interfaceB()->funcB1();
    super->interfaceB()->funcB2();
    super->interfaceB()->funcB3();
}


Output:
No errors or program output.


Create a new paste based on this one


Comments: