[ create a new paste ] login | about

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

GiM - C++, pasted on Apr 9:
/* Michal 'GiM' Spadlinski */
#include <iostream>

class Bar {
    public: mutable int i;
    int getI() { return i; }
    void setI(int x) { i = x; }
};
void foo(Bar const * const p)
{
    p->i = 666;
}

int main(int argc, char **argv)
{
        Bar *bar = new Bar;

        bar->setI(777);

        foo(bar);

        std::cout << bar->getI() << std::endl;
        return 0;
}


Output:
1
2
666



Create a new paste based on this one


Comments: