Hello Terry!
The standard requires that inclusion of <iostream> declares the eight
standard stream objects. Nothing less but also nothing more. Now, you
can declare these objects without even defining their type, you only
need to declare their type. Except for an issue with template default
arguments (*), a valid implementation of <iostream> could look like
this:
#if !defined(_IOSTREAM)
#define _IOSTREAM
namespace std
{
template <typename> struct char_traits;
template <typename, typename> class basic_istream;
template <typename, typename> class basic_ostream;
extern basic_istream<char, char_traits<char> > cin;
extern basic_ostream<char, char_traits<char> > cout;
extern basic_ostream<char, char_traits<char> > cerr;
extern basic_ostream<char, char_traits<char> > clog;
extern basic_istream<wchar_t, char_traits<wchar_t> > wcin;
extern basic_ostream<wchar_t, char_traits<wchar_t> > wcout;
extern basic_ostream<wchar_t, char_traits<wchar_t> > wcerr;
extern basic_ostream<wchar_t, char_traits<wchar_t> > wclog;
}
#endif
I'm not aware of any implementation which really does this but there
are valid reasons to implement it this way. It may appear to result in
a bad user experience but once you have ported a major piece of code
from a heavily extended standard library to another platform you will
appreciate the benefit of a library providing only the bare minimum!
(*) Only the first declaration of a template using default template
arguments is allowed to provide
them. Since basic_istream and basic_ostream are defaulted on the
second argument, the
first declaration actually has to provide these. Since a user can
either include <iostream>
or <istream> first, some preprocessor logic is necessary to make
sure that the template
default arguments go to the right place.
Good luck, Denise.
--
[ See
http://www.yqcomputer.com/ ]
[ comp.lang.c++.moderated. First time posters: Do this! ]