+ 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.

6th Oct 2021, 8:09 AM
Tim
Tim - avatar
6 odpowiedzi
+ 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
6th Oct 2021, 10:58 AM
Rishi
Rishi - avatar
+ 3
Shizuku no problem, cheer up (◠‿・)—☆
6th Oct 2021, 1:07 PM
Rishi
Rishi - avatar
+ 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 😓
6th Oct 2021, 11:17 AM
VlRFIGNoaWxkIHByb2Nlc3MgOTM2NiBsYXVuY2hlZCBieSBnbm
+ 2
Martin Taylor Woah, thanks for putting efforts into answering and explaining everything, wish I could mark all of your answers best
6th Oct 2021, 11:38 AM
Tim
Tim - avatar
+ 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
6th Oct 2021, 8:36 AM
Tim
Tim - avatar
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.
6th Oct 2021, 8:30 AM
VlRFIGNoaWxkIHByb2Nlc3MgOTM2NiBsYXVuY2hlZCBieSBnbm