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

the stream hierarchy
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 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

slide-2
SLIDE 2

The Stream Hierarchy

Inheritance of istream and ostream from ios ios istream

  • stream

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 };

slide-3
SLIDE 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
slide-4
SLIDE 4

Files and Streams

ifstream & ofstream ifstream ifobj (“filename”);

  • fstream ofobj (“filename”, ios::out | ios::nocreate);
  • pen and close functions

Flags:

  • nocreate
  • in
  • out
  • noreplace

Lab Work: Details provided on-line.