0

what does using namespace std do? elaborate each and everything

6th Aug 2016, 11:50 AM
Rajat Gupta
Rajat Gupta - avatar
7 odpowiedzi
+ 2
"using namespace std;" allows you to use the standard namespace without explicitly saying so: #include <iostream> using namespace std; int main() { cout << endl; return 0; } is similar to: #include <iostream> int main() { std::cout << std::endl; return 0; }
6th Aug 2016, 1:38 PM
Samuel Neo
Samuel Neo - avatar
+ 1
Like i said. Im literally half an hour into playing around with everything. Thats just the conclusion I came to. Im sticking around to find the answer out though.
6th Aug 2016, 1:26 PM
Connor Garth
Connor Garth - avatar
+ 1
Well Quantum Chromodynamics, thanks, but what is the standard namespace?
6th Aug 2016, 1:48 PM
Rajat Gupta
Rajat Gupta - avatar
+ 1
Sorry, I don't know much. "std" includes operations such as "cout", "cin" and "endl". If namespaces are not declared as being used after the preprocessor directives, you can use the name of the namespace followed by a "::" to access the operation. For example, #include <iostream> using namespace std; int main() { this_thread::sleep_for(chrono::milliseconds(10)); return 0; } This would call a function "sleep_for" with namespace "std", "this_thread" and class "chrono". (I'm not sure if "this_thread" is a namespace or class)
6th Aug 2016, 1:56 PM
Samuel Neo
Samuel Neo - avatar
+ 1
I found this link if this is of any use - https://www.quora.com/What-does-using-namespace-std-mean-in-C++
6th Aug 2016, 2:00 PM
Connor Garth
Connor Garth - avatar
+ 1
using namespace is a standard for naming such as cout ,cin etc with std these are not recognize and generate error
6th Aug 2016, 7:50 PM
Sajad Hussain
Sajad Hussain - avatar
0
thanks to both of you.
6th Aug 2016, 2:07 PM
Rajat Gupta
Rajat Gupta - avatar