Cogman is right. There is no rule for all situations.
In general, accessors and mutators will allow more forward-compatibility and better encapsulation than direct access, at the cost of a few more characters and a couple of parenthesis here and there.
A style guide (e.g., Google's) might mandate that there are
never public data members... that's someone's opinion of what 'good' code is. The style guide exists to make a large code base homogeneous for the purposes of future maintenance by coders who didn't write the original. Its one small example of practices to follow such that all future coders will be able to quickly identify what is going on in a complicated piece of code. An equally valid rule, from the perspective of homogeneity, is to require that all data members be public, for external inspection at test-time (or to have friend clauses for test classes). One could even require that non-test applications of the object use accessors and mutators, despite data members being public... this all boils down to opinion, either of one person or a consensus opinion of a committee.
Lastly, style guides have to be written
for the weakest coder (remember that thread?

), and adhered to
by all coders, including the strong ones, or it doesn't mean anything. Gurus might be able to get away without object encapsulation (though I don't recommend it except for a 'smart struct' scenario ala Cogman's post), but not all coders will understand WTF is going on.