Click to See Complete Forum and Search --> : problem with new headers, <iostream> vs <iostream.h>


BigArseBear
July 23rd, 2001, 04:47 AM
Hi, when I use the new headers &lt;iostream&gt; etc as opposed to the old &lt;iostream.h&gt; headers ios::nocreate, ios::openprot are all not defined, have they been moved to a new file?

for example this will work:

#include &lt;iostream.h&gt;
#include &lt;fstream.h&gt;

ofstream of("foo.txt",ios::nocreate);

but this wont:

#include &lt;iostream&gt;
#include &lt;fstream&gt;

using namespace std;

ofstream of("foo.txt",ios::nocreate);

mps2
August 22nd, 2001, 01:30 PM
I don't have an answer to your problem but I do have a question related to it. Have you had any problems linking your old VC++6.0 code that includes fstream includes? I have another post on this subject.

Graham
October 1st, 2001, 11:41 AM
The ".h" headers are an archaism - they reflect the old (pre-standardisation) I/O mechanism in C++. The ones you're having trouble with are the standard I/O headers. I fell over this a while back.

There are quite a few differences: for starters, the constants are in ios_base, not ios, but there's no "nocreate" in the new streams standard (the constants are: in, out, ate, app, trunc and binary). Also, the third argument (the "sharing" mode) to the fstreams constructors is missing in the new set.

It's a bit of a comedown from the old style, but blame the standardisation committee for going for the lowest common denominator.



He who breaks a thing to find out what it is, has left the path of wisdom - Gandalf