std::cin

Hello!
can any one explain what's the meaning of :
std::cin
and
std::cout
thanks
std::cin is for standard input from the console.
std::cout is for standard output on the console.

1
2
3
4
std::string name;
cout << "Please enter your name: ";
cint >> name;
cout << "Hello, " << name << "!";
In any program you can put using namespace std; after headers and then you can write cout<<...; or cin>>...; without std::.
On the other hand, you can omit using namespace std; and you can write std::cout<<...; or std::cin>>...; The last way of doing this is better than the first because it doesn't charge the memory with some unuseful functions of std::. Also, if you'll do that in the future, be careful because you can use functions of std:: without knowing that so probably you'll have some errors with a suspicious meaning - to correct them you must put using namespace std;.
In other words: Don't using namespace std;

namespace exists for a good reason, namely avoiding name clash
If you keep the scope as minimum as possible, it's not a big deal. But it's definitely a lot better to just do std::whatever when you need to.
Topic archived. No new replies allowed.