[ create a new paste ] login | about

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

C++, pasted on Aug 25:
#include <iostream>
using namespace std;

class cSingle{
public:
    static cSingle & getInst(){
        return single;
    }
private:
static cSingle single;
};

cSingle single;

class cChild : public cSingle{
    public :
    static cSingle & getBase(){
        return cSingle::getInst();
    }
    static cChild  & getChild(){
        return child;
    }
private:
static cChild child;
};

cChild child;

int main(){
    cChild  &child = cChild ::getChild();
    cSingle &single= cChild ::getBase ();
    return 0;
}


Output:
No errors or program output.


Create a new paste based on this one


Comments: