Headers:
This tutorial explains why not to use unnamed namespaces
in headers.
That's why we get two options to declare non-member functions in headers: Named namespace
vs Inline functions
.
Explain please:
When do you use each?
What's the right way to use them?
- If
Named namespace
then declaration in header and definition in cpp? - If
Inline
then declaration + definition in the header?
Cpp:
I read that using unnamed namespace
is useful only in cpp and it can help to make names internal in the translation unit and avoid name collisions.
If there are any cases to use named namespaces
or inline functions
in cpp?