Topic: STL <iostream> vs. <iostream.h>
Author: clamage@Eng.Sun.COM (Steve Clamage)
Date: 1995/10/09 Raw View
In article mf8@rational.rational.com, "J\ir\tme Desquilbet" <jDesquilbet@Rational.COM> writes:
>
>Reading the STL part of the CD, I understand that the sample "Hello world"
>program becomes:
>
>#include <iostream>
>int main()
>{
> using namespace std;
> cout << "Hello, world!" << endl;
>}
That is one way to write it. There are other ways as well. You could put
the "using namespace" at file scope, or just have using-declarations
for the items you need from <iostream>.
>If yes, what about "old" programs written using <iostream.h>? What does the
>above program become if I want to write it without using namespace std?
The ".h" versions of the standard C++ headers are not mentioned in the standard.
Implementors may supply as many other headers as they like, with any sort of
contents. I would expect a vendor to supply a header corresponding to the
use of <iostream.h> which looked something like this:
#include <iostream>
using std::ios;
using std::istream;
using std::ostream;
using std::cout;
using std::cin;
... etc
Such a header would allow typical existing programs to continue to compile.
---
Steve Clamage, stephen.clamage@eng.sun.com
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Author: "J\ir\tme Desquilbet" <jDesquilbet@Rational.COM>
Date: 1995/10/09 Raw View
Reading the STL part of the CD, I understand that the sample "Hello world"
program becomes:
#include <iostream>
int main()
{
using namespace std;
cout << "Hello, world!" << endl;
}
Am I right?
If yes, what about "old" programs written using <iostream.h>? What does the
above program become if I want to write it without using namespace std?
Thanks in advance,
J r me.
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Author: John Max Skaller <maxtal@suphys.physics.su.oz.au>
Date: 1995/10/10 Raw View
"J\ir\tme Desquilbet" <jDesquilbet@Rational.COM> wrote:
>
>Reading the STL part of the CD, I understand that the sample "Hello world"
>program becomes:
By a using directive:
>#include <iostream>
>int main()
>{
> using namespace std;
> cout << "Hello, world!" << endl;
>}
>
>Am I right?
Thats one way. Here's another with explicit qualification:
#include <iostream>
int main()
{
std::cout << "Hello, world!" << std::endl;
}
Here's another with the compatibility header:
#include <iostream.h>
int main()
{
cout << "Hello, world!" << endl;
}
Here's another with using declarations:
#include <iostream>
using std::cout;
using std::endl;
int main()
{
cout << "Hello, world!" << std::endl;
}
>If yes, what about "old" programs written using <iostream.h>?
Should continue to work. iostream.h looks basically like:
// file: iostream.h
#include <iostream>
using std::cout;
using std::endl;
using std:istream;
...... (all names are 'used')
--
John Max Skaller voice: 61-2-566-2189
81 Glebe Point Rd fax: 61-2-660-0850
GLEBE NSW 2037 email: maxtal@suphys.physics.oz.au
AUSTRALIA email: skaller@maxtal.com.au
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Author: Michael Cook <mcook@cognex.com>
Date: 1995/10/11 Raw View
>>>>> "SC" == Steve Clamage <clamage@Eng.Sun.COM> writes:
SC> The ".h" versions of the standard C++ headers are not mentioned in the
SC> standard.
(...)
SC> Such a header would allow typical existing programs to continue to
SC> compile.
But, of course, every one of those existing programs is non-standard.
Michael.
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Author: "Jirtme Desquilbet" <jDesquilbet@Rational.COM>
Date: 1995/10/13 Raw View
John Max Skaller <maxtal@suphys.physics.su.oz.au> wrote:
>
> #include <iostream>
> using std::cout;
> using std::endl;
>
> int main()
> {
> cout << "Hello, world!" << std::endl;
> }
>
Thanks for your answer.
I suppose you mean:
#include <iostream>
using std::cout;
using std::endl;
int main()
{
cout << "Hello, world!" << endl;
}
And what about <<?
Is not something like:
using std::operator<<;
necessary?
Jerome.
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Author: jDesquilbet@Rational.COM
Date: 1995/10/14 Raw View
John Max Skaller <maxtal@suphys.physics.su.oz.au> wrote:
>
> #include <iostream>
> using std::cout;
> using std::endl;
>
> int main()
> {
> cout << "Hello, world!" << std::endl;
> }
>
Thanks for your answer.
I suppose you mean:
#include <iostream>
using std::cout;
using std::endl;
int main()
{
cout << "Hello, world!" << endl;
}
And what about <<?
Is not something like:
using std::operator<<;
necessary?
Jerome.
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Author: "James M. Curran" <72261.655@CompuServe.COM>
Date: 1995/10/14 Raw View
Distribution:
>> But, of course, every one of those existing programs is
>> non-standard.
Since we as yet have no standard, every one of _ALL_ existing
programs are non-standard.
[Moderator's note: I think that "non-standard" in the original post is
simply shorthand for "non-standard under the assumption that there
will be no major changes to the rules in the current draft." Still,
it's worth remembering that the draft isn't a standard. mha]
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]