Why use iostream and namespace simultaneously?? | Sololearn: Learn to code for FREE!

+8

Why use iostream and namespace simultaneously??

we use <iostream> that contain everything for input and output..then why we use "namespace std;"

5/3/2017 4:55:04 AM

MUʜAMMED ɪʟʟYAS

4 Answers

New Answer

+26

https://www.sololearn.com/discuss/120489/?ref=app

+13

https://www.sololearn.com/discuss/294730/?ref=app

+3

Frost link has good tutorial answer. Here is mine not good as his. No, I personally think it is not good to use "using namespace std;" syntax. It will only make that use cout and other function or object from std class to use like cout << "Hello"; instead of std::cout << "Hello"; When you learn more and code a big program. And suppose you have two class with same function name like their are two different cout object in two different header file. Both use to show output to console and they have their own cons and pros. How would you use them if you have written "using namespace class_name1;". It always refer to function in class_name1. But you need to use function from class_name2. I know it bit difficult for first time, but after that it become easy. Hope you understand it

+3

they are in a way, different things