CPS 6.3,4 Ramm - Fall 2000 - 9/29/00 #15
- Announce
- Quiz Today
- Exam Wednesday
- Select Questions from old Tests
- In-class Review on Monday (Q&A)
- Old Exams On-Line
Chap 6. Classes, Iterators, & Patterns
- Stream Iteration: Counting Words
wordcount.cpp
- Input File Streams
-
#include
-
ifstream streamname
-
streamname.open(filename)
-
streamname >> variable
wordcount2.cpp
- UNIX File Streams
stdin, stdout
- Redirection
-
program < infilename
-
program > outfilename
-
program < infilename > outfilename
- Pipes
-
program1 | program2
-
program1 | program2 | program3
- Filters
- Extrema, Statistics
- Type Casting (coercion)
- Change one type to another
- Only defined where it makes sense
- Several different forms exist
- E.g., changing int to double
- double(n)
- (double) n
- Using Reference Parameters
-
stats3.cpp
-
stats4.cpp
- Text Processing Example
- Design Issues
- Moving Functionality to Functions
- Use of Reference Parameters
-
format.cpp
-
formatwatch.cpp
- More Reference Parameters (tricky)
-
ref.cpp
Chap 7. Class Interfaces, Design, and Implementation
- Switch Statement
- switch ( expression )
- {
- case constant1:
- statement list;
- break;
- case constant2:
- statement list;
- break;
- ...
- default:
- statement list;
- }
- Example Using the Switch Statement