This chapter presents the following content: Using try and catch blocks to handle "Dangerous" method calls, numberformatexception, line plot example, try and catch blocks - more details, two types of exceptions - checked and unchecked, unchecked exceptions, checked exceptions,.and other contents. | CSC241: Object Oriented Programming Lecture No 31 Previous Lecture A linked list data storage class ptr data ptr data ptr data ptr data ptr template struct Node { TYPE data; Node* next; }; template class linklist { private: Node* first; public: void additem(TYPE d); void del(); void display(); }; Today’s Lecture Stream and classes Input and Output stream iostream class ios class Formatting Flags Error-Status Bits File operations Stream Classes A stream is a flow of data (sequences of bytes) In C++ a stream is represented by an object of a particular class For example, the cin and cout stream objects Different streams are used to represent different kinds of data flow For example, the ifstream class represents data flow from input disk files Advantages of Streams Simplicity . using printf and scanf function, there is a need to specify the type of input or output . %d, %f or %c etc. There are no such formatting characters in streams, since each object | CSC241: Object Oriented Programming Lecture No 31 Previous Lecture A linked list data storage class ptr data ptr data ptr data ptr data ptr template struct Node { TYPE data; Node* next; }; template class linklist { private: Node* first; public: void additem(TYPE d); void del(); void display(); }; Today’s Lecture Stream and classes Input and Output stream iostream class ios class Formatting Flags Error-Status Bits File operations Stream Classes A stream is a flow of data (sequences of bytes) In C++ a stream is represented by an object of a particular class For example, the cin and cout stream objects Different streams are used to represent different kinds of data flow For example, the ifstream class represents data flow from input disk files Advantages of Streams Simplicity . using printf and scanf function, there is a need to specify the type of input or output . %d, %f or %c etc. There are no such formatting characters in streams, since each object already knows how to display itself Overload existing operators and functions Use exisiting operator for class in the same way as the built-in types I/O stream classes It represent input and output stream In input stream, the bytes flow from a device (., a keyboard) to main memory In output stream, bytes flow from main memory to a device (., a display screen, a printer) We have already use stream class Extraction operator >> is a member of istream class Insertion operator << is a member of ostream class istream and ostream are derived from ios cout and cin cout object: It representing the standard output stream which is usually monitor It is a predefined object of the ostream_withassign class, which is derived from the ostream class cin object: Represent standard input stream which is usually key board It is a predefined object of istream_withassign class, which is derived from istream Header files IOSTREAM classes used for input and output to the video display and keyboard are