C
Charles L
I have read that the inclusion of <fstream.h> makes the inclusion of
<iostream.h> unnecessary.
Is this correct?
Charles L
<iostream.h> unnecessary.
Is this correct?
Charles L
Charles L said:I have read that the inclusion of <fstream.h> makes the inclusion of
<iostream.h> unnecessary.
Is this correct?
Unforgiven said:First of all, don't use <fstream.h> and <iostream.h>. Use <fstream> and
<iostream> instead.
As for your question: I don't know if that behaviour is standard
defined, but on my system at least (VC7.1) including <fstream> does not
make inclusion of <iostream> unnecessary. So the answer is no.
I'm taking a class in C++ and they use <iostream> rather thanFirst of all, don't use <fstream.h> and <iostream.h>. Use <fstream> and
<iostream> instead.
As for your question: I don't know if that behaviour is standard defined,
but on my system at least (VC7.1) including <fstream> does not make
inclusion of <iostream> unnecessary. So the answer is no.
I'm taking a class in C++ and they use <iostream> rather than
<iostream.h> in the examples.
<isotream> is part of ISO standard C++.
You make it sound like a penance ;-)Keith Meidling said:I'm taking a class in C++ and they use <iostream> rather than
<iostream.h> in the examples.
What is the reason for using one over the other. I know that if
you use the .h you don't have to use 'using std::xxxxxx' statements.
You make it sound like a penance ;-)
Having to use 'using std::xxx' (or prefix names with std:
is a _good_ thing. Typing those few extra characters now may save you a
lot of work later.
Keith Meidling said:How would this save me work?
I don't want to sound like I'm questioning your statement, I'd just
like more info... If it's better to do it this way, hey, I'm all for it
I'd just like to know why to use one or the other...
Charles L said:I have read that the inclusion of <fstream.h> makes the inclusion of
<iostream.h> unnecessary.
Is this correct?
I'm taking a class in C++ and they use said:<iostream.h> in the examples.
What is the reason for using one over the other. I know that if
you use the .h you don't have to use 'using std::xxxxxx' statements.
The technical term is "namespace pollution". The <*.h> headers dump
their contents into the global namespace; the ones without .h define
them in namespace std. With a big enough project, sooner or later
you're going to give one of your functions the same name as a standard
library function, or you'll use a third-party library which does so.
Using namespaces helps to prevent ambiguities.
More subtle, but sometimes more important, is the way the compiler looks
up functions depending on the type of their arguments and the namespace
in which they are defined.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.