Is using namespace std; mandatory? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is using namespace std; mandatory?

26th Sep 2016, 4:22 PM
Supriya P
4 Answers
+ 3
it's mandatory to use it in case you want to use the standard c++ built-in objects like "cout" or "cin" or "endl" directly if you do not add it at your beginning of your cpp source file then you will have to prefix those objects with their corresponding class resolution scope operator, that is replacing "cout" by "std::cout", "cin" by "std::cin" or "endl" by "std::endl"
26th Sep 2016, 8:56 PM
The Artist
The Artist - avatar
+ 1
Well, if you are using dev c++, you can always write "std::" (Something like this, I don't remember it now) before commands, the idea of writing "using namespace std;" is just for more comfortable work.
26th Sep 2016, 8:18 PM
dfsfsdfsdfsasda
dfsfsdfsdfsasda - avatar
0
depends on ur compiler...dont need to if ur using turbo c
26th Sep 2016, 6:06 PM
Pradhit Ongole
Pradhit Ongole - avatar
0
No...Could use header file #include<iostream.h> alone...
29th Sep 2016, 12:47 PM
Sarukrishna
Sarukrishna - avatar