Not sure how that is any different besides construction of an object rather than a file with globals?
In any case, I think variables that are “global” but encapsulated in this way lose the potential for harm we associate with a global variable the whole program may be directly reading and writing.