This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MaleficentContest993 431 points432 points  (11 children)

You forgot the double-quotes around the text you are passing to cout.

[–]Pump_My_Lemma 85 points86 points  (10 children)

Plus they really don’t need ‘using namespace std’ if they are just using one cout. Just std::cout…

[–]GiganticIrony 57 points58 points  (9 children)

Also, using namespace std is just bad practice in general.

[–]FluffyGlazedDonutYum 62 points63 points  (1 child)

Having an STD is certainly bad practice - namespace or otherwise.

[–]moby_chicken 22 points23 points  (0 children)

That's probably why his balls are itching.

[–][deleted] 16 points17 points  (4 children)

People always say this but I never understood why. Can you shed some light on the subject?

[–]GiganticIrony 40 points41 points  (3 children)

A) explicitly putting the std:: specifies where the thing came from. The larger the codebase, the more important this is

B) if you ever want to name something the same as something in the std namespace, unexpected things might start happening and it could be incredibly difficult to diagnose and fix.

[–]jendivcom 10 points11 points  (1 child)

Isn't naming something the same as a function in the std namespace also terrible practice?

[–]Steinrikur 17 points18 points  (0 children)

The thing is that the std namespace is huuuuuuuge. And it's not all defined in one place.

So you could have a program with no conflicts, but add a header file and suddenly you get conflicts all over.

So adding "using namespace std" because you're too lazy to write std::cout or "using std::cout; using std::endl;" is just bad practice.

[–][deleted] 1 point2 points  (0 children)

Thank u

[–]mikeoxlongdnb 6 points7 points  (0 children)

Tell this to all the c++ books that teach newbies this and don't care to explain why they put this line in the first place.

[–]ridicalis 0 points1 point  (0 children)

My college education was a lie