unnamed namespace,

Discussion in 'C++' started by vsgdp, Jul 2, 2006.

  1. vsgdp

    vsgdp Guest

    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?
    vsgdp, Jul 2, 2006
    #1
    1. Advertising

  2. vsgdp wrote:
    > 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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Jul 2, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Razmig K
    Replies:
    3
    Views:
    680
    John L Fjellstad
    Sep 5, 2003
  2. marco_segurini
    Replies:
    4
    Views:
    1,001
    Rob Williscroft
    Jun 16, 2004
  3. marco_segurini

    unnamed namespace and friend

    marco_segurini, Feb 3, 2005, in forum: C++
    Replies:
    1
    Views:
    352
    msalters
    Feb 3, 2005
  4. Marco Jez

    unnamed namespace collision

    Marco Jez, Mar 28, 2005, in forum: C++
    Replies:
    1
    Views:
    449
    Peter MacMillan
    Mar 28, 2005
  5. Sandy

    unnamed namespace problem

    Sandy, Sep 24, 2005, in forum: C++
    Replies:
    3
    Views:
    351
    Robbie Hatley
    Sep 25, 2005
Loading...

Share This Page