#include <iostream>

struct A
{
    int value = 1;

    void printAddress(const char* funcName) const
    {
        std::cout << funcName << " called on object with address " << this << '\n';
    }

    void setValue(int);
    int getValue() const;

    void reset() ;
};

A globalObject;

void A::setValue(int val)
{
    printAddress("A::setValue");
    value = val;
}

int A::getValue() const
{
    printAddress("A::getValue");
    return value;
}

void A::reset()
{
    printAddress("A::reset");
    globalObject.setValue(value);
    setValue(1);
}

int main()
{
    A functionObject;
    
    std::cout << "Address of globalObject: " << &globalObject << '\n' ;
    std::cout << "Address of functionObject: " << &functionObject << '\n' ;
    

    functionObject.setValue(42);
    std::cout << functionObject.getValue() << '\n';
    std::cout << globalObject.getValue() << '\n';

    functionObject.reset() ;       // also manipulates global object.

    std::cout << functionObject.getValue() << '\n';
    std::cout << globalObject.getValue() << '\n';
}
