+ 1

What is the purpose of namespace before main function???

17th Dec 2016, 4:21 AM
Arzed Ali
Arzed Ali - avatar
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....
17th Dec 2016, 4:32 AM
Mock
Mock - avatar
+ 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.
17th Dec 2016, 4:39 AM
Vipul Walia
Vipul Walia - avatar
0
thanks
17th Dec 2016, 4:33 AM
Arzed Ali
Arzed Ali - avatar
0
welcome sir ,
17th Dec 2016, 4:34 AM
Mock
Mock - avatar