Is above code an equivalent to int std::a,std::b,std::c;
No. A using namespace
statement means that your code can use members of that namespace without having to qualify them with the namespace's name.
For example, say you have a #include <string>
statement followed by a using namespace std;
statement. You can then refer to the std::string
class as just string
instead.
Or, say you have a #include <iostream>
statement followed by a using namespace std;
statement. You can then refer to the std::cin
and std::cout
objects as just cin
and cout
, respectively.
Simply using
a namespace does not add anything to that namespace. It is a way of bringing content from the specified namespace into the calling namespace.
If I declared(defined) a namespace Hi
after the line using namespace std;
. Is Hi
a part of std
No. To do that, Hi
would have to be declared inside of a namespace std
block, eg:
namespace std {
namespace Hi {
...
}
}
But, that is undefined behavior (except in special cases), as you are generally not allowed to add things to the std
namespace.