using std::iostream ?

This might be an easy question for most of you I guess.

I want to use "using std::iostream" or similar first in my cpp-files. This is because I have a lot of "cout" and "endl" in my code and it would be dirty code if I have to replace it with "std::cout" and "std::endl". See the attached file for a complete project in VC++ 6.0. But the compiler won't allow this. It won't recognize the cout and endl words, why?

/Roland
d98rolbSystem Developer Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SteHCommented:
You can use the line
using namespace std;
infront of all occurances of cout and endl to achieve this.
0
jkrCommented:
>>It won't recognize the cout and endl words, why?

I assume you are not using the correct namespace - try adding

#include <iostream>
// other STL headers...
using namespace std; // <-- !
0
TobberCommented:
Hi.

Use "using namespace std;" istead. cout and endl are both members of the std namespace.

/T
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

d98rolbSystem Developer Author Commented:
Hi again, I forgot to say that the VC++ project file can be downloaded on http://hem.passagen.se/d98rolb3/uploads/Lista.zip (15 kb)

0
d98rolbSystem Developer Author Commented:
I don't want to use the simple solution in the start of each file:

using namespace std;

This introduce hard to find errors later in the project because the whole namespace is visible.
0
bcladdCommented:
Okay:

Where you would have put using namespace std; you can import only the items you want:

using std::cout;
using std::cin;
using std::endl;

-bcl
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jkrCommented:
>>I don't want to use the simple solution

Hum.

>>This introduce hard to find errors later

Which errors?
0
d98rolbSystem Developer Author Commented:
using namespce std;
reveal the whole namespace for the program, proffessional programmers don't use it, and I have now learned why...


0
jkrCommented:
>>proffessional programmers don't use it

OK, so you are suggesting that I am acting 'unprofessional'? That's a bummer, gonna have to quit my job...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.