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!
cout in C++. The cout object in C++ is an object of class ostream. It is defined in iostream header file. It is used to display the output to the standard output device i.e. monitor. It is associated with the standard C output stream stdout.
It is used to display the output to the standard output device i.e. monitor. It is associated with the standard C output stream stdout. The data needed to be displayed on the screen is inserted in the standard output stream (cout) using the insertion operator (<<).
Let us start with your function. Since you just want to write something to the console, using cout, you do not need the return value ( see the comments in the code, char is changed in void ). Also, I have changed cout statement to output the ocean string, that you have passed to the function, see the code.
Please Sign up or sign in to vote. I have rewritten your code, so you can see your mistakes. Let us start with your function. Since you just want to write something to the console, using cout, you do not need the return value ( see the comments in the code, char is changed in void ).
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
.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With