+ 1
What is the purpose of namespace before main function???
4 Antworten
+ 2
as we are familiar with :
using namespace std;
in every programs, Standard library has thousands of function in it .. those names may be similar to your own function name at program in such scenario compiler throw error.
to avoid naming collision from standard library In program we use namespace.
and it also makes life easy
when your not using namepace
std::cout <<" hello world!";
cout is the function of standard library so we have to define std before with scope resolution cout that's makes life tedious.
Hope you understood....
+ 1
A namespace is designed to overcome this difficulty and is used as additional information to differentiate similar functions, classes, variables etc. with the same name available in different libraries. Using namespace, you can define the context in which names are defined. In essence, a namespace defines a scope.
0
thanks
0
welcome sir ,