ECS 36B Lecture 16: Streams and Overloading

48 views4 pages
Verified Note

Document Summary

Ecs 36b - lecture 16 - streams and operator overloading. Generalizes your program"s different sources of input characters. Creates a general place for user to put characters. Some common examples of streams are: files, the keyboard, terminal output, and sometimes even strings. To use a file stream, we must #include on top first. Note that file streams further have different types: for reading from a file, writing to a file, and doing both. When using streams, if you include the file name within the constructor, the file will automatically be opened. There will be no need to add a fopen() Also, to close a file one can call stream. close() or once that stream gets destroyed it automatically closes the file as well. It can be seen that with strings, manually opening and closing files are mostly emitted -- this prevents memory leaks/open files. Stream. isopen() will return true or false depending on if that file is opened or not.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents