I would like to know how it works...
In the <iostream> header, there is namespace std:
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
namespace std {
extern istream cin;
extern ostream cout;
extern ostream cerr;
extern ostream clog;
extern wistream wcin;
extern wostream wcout;
extern wostream wcerr;
extern wostream wclog;
}
So, cout is the name of an object of type ostream, and that is defined in another file (due to extern). Ok.
When I tried in my simple program to create an ostream object, I can't, because the constructor of ostream class is protected. Ok.
So, how can I create (define) an object in an extern file, which has a protected constructor, and looks like a global variable?