the stream hierarchy
play

The Stream Hierarchy Inheritance of istream and ostream from ios - PDF document

17 . Input/Output Mechanism: Standard IO, File IO Standard Input/Output stdin cin stdout cout stderr cerr Input/Output Streams: istream & ostream Input/Output of Built-in Types Input/Output of User-defined Types The Stream Hierarchy


  1. 17 . Input/Output Mechanism: Standard IO, File IO Standard Input/Output stdin cin stdout cout stderr cerr Input/Output Streams: istream & ostream Input/Output of Built-in Types Input/Output of User-defined Types

  2. The Stream Hierarchy Inheritance of istream and ostream from ios ios istream ostream Stream States class ios { //... public: int eof() const; // end of file seen int fail() const; // next operation will fail int bad() const; // Stream corrupted int good() const; // next operation might succeed };

  3. Formatting Output class ios { public : //... int width(int w); // set field width int width() const; // return field width char fill(char); // set fill character char fill() const; // return fill character int precision(int); // set floating point precision int precision() const; }; Manipulators • setw • setfill • setprecision • oct • hex • dec • setbase

  4. Files and Streams ifstream & ofstream ifstream ifobj (“filename”); ofstream ofobj (“filename”, ios::out | ios::nocreate); open and close functions Flags: • nocreate • in • out • noreplace Lab Work: Details provided on-line.

Recommend


More recommend