This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Scope of "using namespace std;"

Hi,

With enabling of C++ support in my nCS project, i was able to include "using namespace std" and successfully build.

However, i wasn't able to use C++ std keywords like cout,endl, etc,.

So can you please help me understand what do i gain by adding "using namespace std" in my project..? Does it enable any std C++ features..?

Thanks,

Ubaid

  • Hi Ubaid

    All that the 'using' keyword does is remove the requirement to include the namespace name in front of any identifier within that namespace (allowing you to write cout instead of std::cout for instance). 

    You still have to include the right header file to get access to the functions you want to use. In the case of cout and endl you need to include iostream:
    #include <iostream>

    Could you try with the include and see if it works?
    If it still doesn't work, will it work the normal way (using std:: in front) ?

    Best regards
    Torbjørn

Related