A namespace is a scope region which contains names. A namespace identifies where the particular name (a function, types etc). reside.
A namespace can only have declarations and definitions. It does not allow executable statements such as assignments, as shown below.
int b;
b = 1;
int main()
{
return 0;
}b = 1 gives compilation error as it is an executable statements being used in global namespace.
std namespace
This is standard library namespace where we use std::cin and std::cout. :: is called scope resolution operator. Left operand tells the namespace and right tells the name in the namespace.
If used without left operand, it takes global namespace by default. For example,
#include <iostream>
int b{1};
int main()
{
std::cout << ::b; // uses b from global namespace.
return 0;
}We can use using-directive and using-delcaration to use namespace directly without specifier namespace name with scope resolution operator.