On Sat, Nov 27, 1999 at 04:54:04PM +0000, kevin lyda wrote:
> Mel wrote:
> > cout instead of ifstream
> > fstream instead of fopen
> > new instead of malloc
>> i take this as libc's stdio vs. c++'s stl streams. (i'm not a c++
> person, but my understanding is that there used to be a c++ lib -
> #include <streams.h> for example - and now there's the stl with #include
> <streams>) one argument might be efficiency. stdio has been studied a
> great deal and the idea has been to reduce data copying. now how much
> studying has been put into making the stl efficient? dunno.
You are mixing up the C++ Standard Library (the analog of the
standard header files in ANSI C providing I/O, string support,
and other stuff) and the Standard Template Library (STL) which
provides generic container, iterator and algorithm classes
such as lists, queues, maps, sorts, and other stuff. STL
uses C++ templates to provide type-safe support for any data
C++ I/O streams are nothing to do with STL.
Mind you, as far as I'm concerned, << means left shift,
not "format in some hard-to-specify way for shoving up
an ostream". But that's just a personal taste thing...
And the difference between #include <streams.h> and
#include <streams> is that the .h version puts the
definitions into the global namespace, whereas the
newer non-.h version puts them in the std:: namespace.
So if you do a #include <streams>, you'll have to do
cout << "hello, world\n";
std::cout << "hello, world\n";
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!