r/cpp_questions • • 13d ago

OPEN cpp class vs namespace

in my personal opinion, at least half of the purpose of using nested namespace is to manage visibility, the rust's mod allows it but cpp's namespace does not, only class allows it( the public and private)

is using classes with static functions inside everywhere instead of using namespace an already existing way to use the "namespace" in a way that i can more conveniently manage visibility?

3 Upvotes

13 comments sorted by

View all comments

Show parent comment

1

u/neppo95 13d ago

Yup, sounds good. Now put all of that code inside a singular namespace in case of a library and you’re golden. If its an executable or otherwise code that won’t get used outside the project, that can be omitted although you’d still run into conflicts possibly for libraries you use.