A Tour of C++ (C++ In-Depth Series) by Stroustrup Bjarne

A Tour of C++ (C++ In-Depth Series) by Stroustrup Bjarne

Author:Stroustrup, Bjarne [Stroustrup, Bjarne]
Language: eng
Format: epub
Publisher: Addison-Wesley Professional
Published: 2013-09-19T00:00:00+00:00

if (cin.eof()) {

// .. all is well we reached the end-of-file ...

}

else if (cin.fail()) { // a potentially recoverable error

cin.clear(); // reset the state to good()

char ch;

if (cin>>ch) { // look for nesting represented by { ... }

switch (ch) {

case '{':

// ... start nested structure ...

break;

case '}':

// ... end nested structure ...

break;

default:

cin.setstate(ios_base::failbit); // add fail() to cin's state

}

}

}

// ...

}

8.5. I/O of User-Defined Types

In addition to the I/O of built-in types and standard strings, the iostream library allows programmers to define I/O for their own types. For example, consider a simple type Entry that we might use to represent entries in a telephone book:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Web Analytics