#include <iostream>

using namespace std;

class Foo {
    int x = 0;
public:
    void inc() { x++; }
    int  get() { return x; }
};

class Bar {
    Foo *f;
public:
    Bar(Foo *foo) { f = foo; }
    int get() const { f->inc(); return f->get(); }
};

int bar(const Bar &bar) {
    return bar.get();
}

int main() {
    Foo f;
    Bar b(&f);
    cout << f.get() << endl;
    cout << bar(b)  << endl;
    cout << f.get() << endl;
}