Why can I change a variable in .cpp if it is private in .h and in theory I have to do a getter method to access it?

A class always has access to it’s own private variables, other classes (not designated as friend class) and child classes do not and would require a getter.