[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CppUsing

(C++) using

Keyword that enables you to change the namespace in use. The most common namespace to be in is namespace std. You can set the namespace using 'using namespace' or call the namespace and use the scope operator, ::).

You probably shouldn't use namespace std in your code, because it pollutes the global namespace [1,2].

Don't write namespace usings in a header file or before an #include [3].

Hello world program using 'using namespace'

  1. include <iostream>
using namespace std; int main() { cout <<"Hello World" << endl; return 0; }


Hello world program using scope operator

  1. include <iostream>
int main() { std::cout <<"Hello World" << std::endl; return 0; }


Code links

'using' links

References



last edited (December 3, 2006) by bilderbikkel, Number of views: 3998, Current Rev: 11 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.