0

What is using namespace std. I didn't understood it

in my book there is no command like using namespace std

24th Nov 2017, 7:56 AM
Aryan Jaiswal
Aryan Jaiswal - avatar
3 Respostas
+ 5
The namespace std stands for the standard namespace. Wow, what does that do? Basically, it is needed for many different uses, the simplest of which are cout and endl. Let's have an example. #include <iostream> using namespace std; int main(){ cout << "Hello World" << endl; return 0; } //Hello World So far, so good. Simple, you might say. Now, suppose we eliminate the second line: #include <iostream> int main(){ cout << "Hello World" << endl; return 0; } //Error: 'cout' was not declared in this scope (same for endl, by the way) As you can see, you need the namespace std to access some important functions. However, if you're using multiple namespaces, it is usually better to do this: #include <iostream> int main(){ std::cout << "Hello World" << std::endl; return 0; } //Hello World Hope this helped. 😉
24th Nov 2017, 11:41 AM
blackcat1111
blackcat1111 - avatar
+ 1
using namespace std let u access to standard library in cpp such string or vector , if u dont , for example to use tge cout , u have to access to it using :: , std::cout , so to make it simple , u use std namespace and just call cout
24th Nov 2017, 8:16 AM
Maher Zaidoune
Maher Zaidoune - avatar
0
its just a library and you dont need to think about that much if you are a beginner
24th Nov 2017, 9:10 AM
Faris81
Faris81 - avatar