CPS 6, Ramm - Summer Semester I - 6/4/99 #11
- Announce
- Review of parts of Test
- Random Quiz #5 due Monday
- Assignment #4
Chap 6. Sequential Access: Streams & Iterators
- Reference Parameters
- Arguments NOT copied
- (Value parameters, used so far, are copied)
-
stats3.cc
-
stats4.cc
- Text Processing Example
- Design Issues
- Moving Functionality to Functions
- Use of Reference Parameters
-
format.cc
-
formatwatch.cc
- More Reference Parameters (tricky)
-
ref.cc
Chap 7. Class Design and Implementation via Simulation
- Switch Statement
- switch ( expression )
- {
- case constant1:
- statement list;
- break;
- case constant2:
- statement list;
- break;
- ...
- default:
- statement list;
- {
- Frogs that can't make up their minds ...
- Random Walks (1-D)
- Physics
- Statistical
- Coin Toss
- Frog Example
- Gambling Example
- Random Walk Class
- Random Walks (2-D)
- Walk Oberver Class (1-D)
- Passing a Class by Value/Reference
- Done for strings many times...
-
scopedice.cc
- Other Tools for Designing Classes
- Enumerated Types - Syntax
-
enum identifier {value, ..., value};
-
enum identifier
{value=int, ..., value=int};
- The Coin Class
-
flip.cc
-
coin.h
-
coin.cc
- Initializer Lists - Syntax
- ClassName::ClassName()
- :
- myVar1(argument),
- myVar2(argument),
- ...
- myVarN(argument)
- {// begin constructor body ...
- Structs
- Similarity to Class
- All Public, No Private
- Can Have Member Functions
- An Aggregate of Dissimilar Types
- Example (without member functions)
- struct Student
- {
- string name;
- int height; // height in inches
- double weight; // weight in pounds
- string dob; // date of birth mm/dd/yy
- }