Laboratory 7: Streams
Goal:
1. To understand how to use C++ object-oriented stream input/output.
2. To be able to format inputs and outputs.
3. To understand the stream I/O class hierarchy.
4. To understand how to input/output objects of user-defined types.
5. To be able to create user-defined stream manipulators.
6. To be able to determine the success or failure of input/output operations.
7. To be able to tie output streams to input streams.
- Notes (ppt) (pdf)
- Streams & Serialization
student.cpp
main.cpp
student.h
(Makefile student.make)
To run this example you will have to supply command line arguments:
c:\work>student "123 Santa" "456
Scrooge" "111 Barbie"
c:\work>type students.txt
Study how operator<< and operator>> are
implemented. This program uses the same implementation of these operators to
read from strings and from a file and to write to a file and to the screen.
Explain how it is achieved by I/O abstraction!
- Instantiating objects from a stream with inheritance
ser.cpp
Study the code and read along in your notes! What is the issue? How is it
solved?
- Codes