Sign in to follow this  
adam_o

iostream header

Recommended Posts

Hello all, In my code, I use #include<iostream.h> so that I am able to call a "cout" command. My Xcode compiler (see below for specs) says that this is an "deprecated or antiquated" header. It then suggests using <iostream> instead of <iostream.h>. When I call that header, it gives me an error saying that "cout" was not declared. What gives?

Share this post


Link to post
Share on other sites
Use <iostream>.

To find cout, you need to let the compiler know that it'll be part of the 'std' namespace.

Either explicitly do it with: std::cout << "foo!" << std::endl;
Set std as the default namespace for the whole file (insert "using namespace std" at the top of your file, after includes)
Set std as the default namespace only for those symbols (at the top of the file, include "using std::count; using std::endl")

Share this post


Link to post
Share on other sites
Quote:
Original post by raz0r
cout lives in the std namespace.

Oh. Forgot about that... well problem solved thank you!

EDIT: Thank you both. I didn't see richards post when I posted.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this