What is namespace in C++?

What is namespace in C++?

In this chapter of C++ interview questions, we will learn about:

  • what is namespace in c++?
  • syntax of namespace in c++
  • application of namespace in C++

Namespace in C++ meaning

Namespace was introduced by ANSI C++ standard committee. A namespace is used to define the scope of identifiers on the program. It also organizes code in groups, so that no name collision takes place.

In C++, the global namespace is the main. It has some features like:

  • Multiple blocks with the same namespace are allowed.
  • A namespace can be present in a nested way.
  • Namespace doesn't need any semicolon after the bracket closes, also it doesn't require an access specifier.

Syntax of namespace in C++

namespace namespace_name


/* Coding Area */


Application of namespace in C++:

using namespace std;

The using namespace is there to that the member defined in std namespace will be used frequently.

cpp interview questions

Would you like to see your article here on tutorialsinhand. Join Write4Us program by

About the Author
Subhajit Guha Thakurta
Page Views :    Published Date : Jan 18,2021  
Please Share this page

Related Articles

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!