Where to namespaces and functions go?

closed account (Ey80oG1T)
So I know that classes can go in a separate .cpp and .h file. But where do I put functions or namespaces? Do they also follow the same a classes? So the declaration of a function is in a .h file, and the definition in the .cpp file? And what about user defined namespaces?
If we are being technical, function declarations go in a header file and the definitions go in a source (cpp) file. Namespaces go wherever yuu want to wrap something in a namespace or use something from an existing namespace. For example, if you have a bunch of function declarations inside of a header file, and you wrap all the functions in a namespace, then the corresponding source file where the functions are defined should also be wrapped in a namespace with the same name.
functions are always by design visible to any TU

so namespace is needed to constraint that common visibility to be unique in a certain TU

identifier names for variable and class (I am not sure for this latter) are opposite by design

All must obey ODR
Topic archived. No new replies allowed.