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!
New to Xcode, can't use cout, only std::cout works
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
.)
I had the same problem but I fixed it. You can simply write the following after the #include
:
using namespace std;
© 2022 - 2024 — McMap. All rights reserved.