Sharing an object instance between multiple classes


I am currently trying to figure out how to share a instance of a structure between multiple classes.

I have a config.hpp file where I declare the structure

struct Config {
    bool enabled;
    int serverPort;

I have a service.cpp class where I’m trying to set both members of the structure,
and in another file, in the main function I’m trying to retrieve the values of both members.

Both service.cpp and the file with the main function include the config.hpp file.

What would be the best approach to solve this problem, without using global variables?

Source: Windows Questions C++