Project 1 -- now three late days, if turned in today...Late Days (re-visited)
CS151 -- Administration
Project 2 -- mailing list, today, probably this afternoon.
Quiz 1
CS151 -- Shawn Stoffer
Functions
Purpose
- Encapsulation
- Separation of ideas
Functions
Scope
- Not mouthwash!!! ;-)
- How long a variable is visible, and exists
- Effectively how long you can use a variable
Functions
Scope
- Global
Functions
Scope
- Global
- Visible everywhere in the program
- Declared outside EVERY block!
- Just declare the variable, nothing special...
Functions
Scope
- Global
- Static -- the three meanings...
Functions
Scope
- Global
- Static -- the three meanings...
- uses special static keyword:
static double myNumber;
Functions
Scope
- Global
- Static -- the three meanings...
- static on global variables to limit scope
Functions
Scope
- Global
- Static -- the three meanings...
- static in a block, functions only
- continues to exist, not re-allocated every function execution.
Functions
Scope
- Global
- Static -- the three meanings...
- In a class member variable
- all objects of that class share one variable
Functions
Scope
- Global
- Static -- the three meanings...
- Local
Functions
Scope
- Global
- Static -- the three meanings...
- Local
- Only visible in their current block
- when execution leaves the block, de-allocated
Functions
Scope
- Global
- Static -- the three meanings...
- Local
- Blocks
Functions
Scope
- Global
- Static -- the three meanings...
- Local
- Blocks
- Everything between { and }
- when you exit a block normally (return or execution steps out of a block) all variables of the block are de-allocated.
- frames of execution
Classes
User defined data typeTerminology
Classes
User Defined Type
- Allows you to make a new type...
- combination of other types
- nothing REALLY new...
Classes
Terminology
- class
- abstract
- object
- instance
Classes
Terminology
- class
- abstract
- There is some type of thing called a person...
Classes
Terminology
- object
- instance
- Joe is a person
Classes
Usage
- declaration:
- className variableName;
- iostream cout;
- fstream fout;
- string myString;
Classes
Usage
- declaration:
- className variableName;