+ 3
For every new code, is it necessary to identify a header #include <iostream>, as well the name space? I thought one should do?
#include <iostream> using namespace std;
3 Réponses
+ 8
Still trying to get used to not doing 'using namespace std'. For each time I forget to do std:: without it and the compiler throw errors, it feels like coming back from school and suddenly your mom doesn't recognise you lol.
+ 3
No, neither are neccessary.
#include <iostream> is just adding the iostream functions to your program so you can use them, such as cin and cout.
Try to take away the #include. No, you will not have any problems.
Now try to write cout << "lel";
Uh oh, what is cout? Never heard of it, says the compiler.
Now put back the iostream header.
What happens if I dont say namespace std?
Well, now I have to write:
std::cout << "lel"; If i want to use cout.
As it is in the standard namespace.
- 2
yes. needed for everyone