+ 6

Cpp Question 😎

Why do we use the 'std::cout' when can use only cout <<?

8th Apr 2018, 3:48 AM
Eric Lecorps
Eric Lecorps - avatar
8 Respuestas
+ 6
This one got some attention in the answers: https://www.sololearn.com/Discuss/1004636/?ref=app
8th Apr 2018, 3:57 AM
Kirk Schafer
Kirk Schafer - avatar
+ 6
Since the introduction of using namespace std, there have been arguments about whether it is a good or bad thing. I don't like it because it puts tons of symbol names into your global scope. These names are so numerous that it is likely you don't know them all. You could plan on overloading one of the names and forget to declare it. Now you end up sharing the standard one with random side effects.
8th Apr 2018, 4:00 AM
John Wells
John Wells - avatar
+ 4
This is will tell you about std:: and using namespace std; https://www.sololearn.com/Discuss/294730/?ref=app Example code without using namespaces https://code.sololearn.com/cUx55EsTKnaz/?ref=app
8th Apr 2018, 4:18 AM
ZΛRTHΛИ
ZΛRTHΛИ - avatar
+ 2
You can only use cout by itself if you have added a using statement for the std namespace. Otherwise you'd receive an error.
8th Apr 2018, 3:55 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
John Wells I was very recently digging into gcc and found files like these: https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/c_compatibility/stdio.h ...so when I #include <stdio.h> I think I get this file, which is basically ~50 lines that read: using std::keyword; // times 50 ...is this an easy example of the globals issue?
8th Apr 2018, 4:25 AM
Kirk Schafer
Kirk Schafer - avatar
+ 1
Eric Lecorps are you brother of Jayden Lecorps
28th Apr 2018, 1:47 AM
Sharofiddin
Sharofiddin - avatar
0
That file is meant to be used in C code, where there you automatically get all the names in global scope for the files you include.
8th Apr 2018, 9:04 AM
John Wells
John Wells - avatar
0
hello Eric what programming language are u learning
11th May 2018, 7:06 PM
Dailen Rogers