unnamed namespace,

V

vsgdp

I just want to clarify: Say I have a helper class that is only used in one
translation file (e.g., a predicate class). I don't want the name of this
class to conflict with other class names in other files, so I put it in a
nameless namespace?
 
V

Victor Bazarov

vsgdp said:
I just want to clarify: Say I have a helper class that is only used
in one translation file (e.g., a predicate class). I don't want the
name of this class to conflict with other class names in other files,
so I put it in a nameless namespace?

That's one very important use for unnamed namespaces, yes. Generally,
anything you think of putting in the global scope (or any other scope
that transcends a single translation unit), but don't want to be easily
visible in another translation unit, or potentially conflict with some
other name, belongs in unnamed namespace.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top