public member class
<ios> <iostream>

std::ios_base::Init

class Init;
Initialize standard stream objects
The construction of an object of this member type, ensures that the standard stream objects (cin, cout, cerr, clog, wcin, wcout, wcerr and wclog) are constructed and properly initialized.

The class maintains an internal static counter with the number of existing objects.

1
2
3
4
5
6
class ios_base::Init {
  static int init_cnt;  // internal static counter (for exposition only)
public:
  Init();
  ~Init();
}

Member functionss

Init(); (constructor)
Increases the internal static counter by one. If the value of the internal counter was zero, the standard iostream objects are constructed and initialized, if they have not yet been constructed and initialized.
~Init(); (destructor)
Decreases the internal static counter by one. If the value of the internal counter reaches zero, the standard output streams are flushed (as if their respective flush members were called).
Notice that this does not destroy any of the standard objects, whose duration lasts until program termination.

See also