Google News
logo
CPP - Interview Questions
What is namespace in C++?
If there are two or more functions with the same name defined in different libraries then how will the compiler know which one to refer to? Thus namespace came to picture. A namespace defines a scope and differentiates functions, classes, variables etc. with the same name available in different libraries. The namespace starts with the keyword “namespace”.

The syntax for the same is as follows :
namespace namespace_name {
   // code declarations
}
Advertisement