Menu

using namespace std; in the C++ header file

Help
2003-02-21
2003-03-02
  • Nobody/Anonymous

    Hi,

    I noticed that all generated files have

    using namespace std;

    at the very beginning. That sentence will pollute the program's namespace. Any way to not generate that sentence in the header file?

     
    • Alec Panovici

      Alec Panovici - 2003-03-02

      No, there is currently no way of not getting it inside the generated sources (maybe in the next version). However, you can always avoid importing the parser's namespace in the rest of the project by using this technique (hopefully i remember this well, i think you can find it in Stroustrup's anyway):

      namespace polluted {
      // hide all this stuff from the rest of your code...
      #include "my_parser.hh"
      using namespace cppcc;
      }

      // ... then explicitely bring in what you need.
      using polluted::MyParser;

      Alec.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.