+ 1
How to include certain functions without importing the whole namespace
I've been told that it's bad to include the whole std namespace, but I don't know how I can include certain functions like cout, cin, endl.
9 Respuestas
+ 3
Shizuku what you mean by "you can't include them without \"using namespace\" syntax"? We include them using #include directive, "using namespace" syntax only let's us use the functions without mentioning the name of the namespace
+ 3
Shizuku no problem, cheer up (◠‿・)—☆
+ 2
Rishi Oh my mistake, without --> with
I thought he is confused with using namespace and include, what Martin Taylor says is correct.
Fixed for no more confusion to not arise... sorry 😓
+ 2
Martin Taylor
Woah, thanks for putting efforts into answering and explaining everything, wish I could mark all of your answers best
+ 1
Martin Taylor
Thank you, is it there a way to put all of the functions I need from the standard library into one line, or it is the way it is
0
You can use those symbols (cin, cout …) by simply prefix std:: to their name.
e.g.) std::cout << "Hello" << std::endl
But probably you can't include them with "using namespace" syntax.