Results 1 to 4 of 4

Thread: using namespace or std:: ?

  1. #1

    Thread Starter
    Hyperactive Member Emo's Avatar
    Join Date
    Jul 2000
    Posts
    428

    using namespace or std:: ?

    Hello... havent been here in YEARS... lol yeah years..

    anyway... I have a quick question:

    I see different sources do this differently so I wanted to know witch one to stick with and what is better:

    should I use the "using namespace std;" OR on every line it should look like "std::cout << " and so on

    Thanks a lot
    -Emo
    -=VB6 Enterprise Edition=-
    -=VC++6Enterprise Edition=-
    «¤E³m°O²™¤»

  2. #2
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    Re: using namespace or std:: ?

    It really depends. For a small project, go ahead and through the entire namespace in there. Chances are you won't have a naming conflict. In a large project, you probably wont have a naming conflict either, but the chances are a lot greater.
    Anyway, There is a third option . You can pick certain items from the namespace to use:

    Code:
    using std::cout;
    using std::cin;
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  3. #3
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: using namespace or std:: ?

    I would suggest never to use a using namespace statement instead of a header file.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: using namespace or std:: ?

    There's just one rule, everything else is a matter of taste.
    The rule is: never use using at the top level of a header file.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width