Why do we use "Using namespace std;" in cpp
what is the use of Namespace & What is namespace or namespace std; in c++:
it is a special feature introduced in cpp, and with its help, we can prevent duplication in the program of variables and especially of methods(Functions()) For Ex, if we working with any xyz() and it is also present in the standard library then compiler gets exerts an error to us due duplicate function in the same directory
but with the use of it, we can overcome this error
Namespaces allow us to group named entities that otherwise would have global scope into narrower scopes, giving them namespace scope. This allows organizing the elements of programs into different logical scopes referred to by names. Namespaces provide the space where we can define or declare identifiers i.e. names of variables, methods, classes, etc.
Why do we use using namespace std;
first, we should know what is the use of it
by this, we tell the compiler that we are using all the entities present in the particular directive(std)
std is the very major and rigid namespace directive of C++ in which all the function or methods, data types, cout,cin etc entities are present like
vectors, strings, arrays etc are part of the namespace std.
Now hope u will understand what a namespace is
if you want more profound & clear information go through this: NAMESPACE
Comments
Post a Comment