New to Xcode, can't use cout, only std::cout works
Asked Answered
D

2

5

I'm not new to programming but I am new to C++ using Xcode as the IDE. I am not allowed to use cout << "hello"; to print, the compiler complains and only works when I use std:cout <<. What setting in Xcode should be fixed in order to get this working the way I'm supposed to write it for class? Thanks!

Domela answered 5/10, 2013 at 20:43 Comment(0)
D
7

Add using std::cout; somewhere close to the start of your program, after the includes.

Please avoid the temptation to use using namespace std;. It's really a bad habit. Just because you see other people doing it, doesn't make it right. See the FAQ: Why is "using namespace std" considered bad practice?

(Or, of course, you could just get use to typing std::cout.)

Ducan answered 5/10, 2013 at 20:45 Comment(0)
K
0

I had the same problem but I fixed it. You can simply write the following after the #include:

using namespace std;
Killingsworth answered 22/5, 2019 at 11:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.