CPS 6L.2 Ramm - Fall 2001 - 10/10/01 #19
7. Class Interfaces, Design, and Implementation
- Implementing and Using Classes
- Iterative Enhancement
- Using Stubs
- Sometimes partial function
- Sometimes announce only
- Sometimes totally empty
teststudent.cpp
question.h
- Other Practical Issues
- Handling different kinds of questions
- String return type for answer
- string tostring(int)
- string tostring(double)
- Question Class
-
mathquest.h
-
mathquest.cpp
- Initializer Lists - Syntax
- ClassName::ClassName()
- :
- myVar1(argument),
- myVar2(argument),
- ...
- myVarN(argument)
- {// begin constructor body ...
- Quiz Program
- Includes Student and Quiz Classes
-
quiz.cpp
- Alternate Question Class (State Capitals)
- Includes Student and Quiz Classes
-
capquest.cpp
-
capquest.h
- 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)
- Passing a Class by Value/Reference
- Done for strings many times...
-
scopedice.cpp
- 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
- }