CPS 6, Ramm - Spring 2000 - 1/28/00 #6
- Announce
- Hope you enjoyed the snow! (Chant didn't work ;-)
- Quiz Monday; then back on Track?
- Labs
Chapter 2: C++ Programs: Form and Function
- Assignment Statement: ... = ...
- Snuck it into the last program
- Pronounce gets rather than equals
- Value of Relational Operations
true = 1
false = 0
- Logical Operators
- Short Circuit Evaluation
exhaust4.cpp
- C++ Operator Precedence
| ! | NOT
|
| *, /, % | mult, div, mod
|
| +, - | add, subt
|
| <<, >> | insert, extract
|
| <, <=, >, >= | LT, LE, GT, GE
|
| ==, != | EQ, NE
|
| && | AND
|
| || | OR
|
| =, +=, -=, *=, /=, %= | assignment
|
When in doubt, parenthesize
- Functions that Return Values
math.cpp
- Writing
Double Functions
tfuncts.cpp
- Use Functions Like Variables
- Writing
string Functions
getgrade.cpp
getgradealt.cpp
- Design Different "Curving" Functions
- Writing Functions
Design Different "Curving" Functions
- Look at
numtoeng.cpp in Book
- The
string Member Functions
string demo = "Monday morning";
- Length:
int length()
demo.length() == 14
- Substring:
string substr(int pos, int len)
demo.substr(7,4) == "morn"
- Find:
int find(string s)
demo.find("y m") == 5
(not found: string::npos )