CPS 6L.2 Ramm - Fall 2001 - 8/31/01 #3
- Announce
- Roll
- Assignment #0
- Lab #1 starts Tuesday
- Friday Quizzes start next week
Chapter 2: C++ Programs: Form and Function
- Functions with Parameters
Flexibility/Versatility
page.cpp
- Functions with several parameters
announce.cpp
Order of parameters is critical
- Functions Invoking Functions
diamond2.cpp
Allows arbitrary depth of abstraction
- Order of Functions
mondias.cpp
The compiler doesn't "recognize" certain names
when first encountered; makes "assumptions"
diamondsp.cpp
- Function Prototypes - Syntax
return-type function(type name, type name, ...);
return-type function(type, type, ...);
===>>> ;
- Let's Design a Program (based on class input)
Requirements:
- Some kind of "graphic" output (char plot)
- E.g., multi story building
- Use functions
- Have functions use functions
- Minimize repetition
Questions:
- Do we need prototype statements?
- What language features could we use?
- More on Style
- Indenting
- Braces on separate lines
- Good Identifiers
- Identifiers/Syntax
- letters, digits, underscore
- do not start with digit
- case sensitive
- arbitrary length
- do not use reserved words
- Identifiers/Style
- meaningful identifiers
- user defined functions & types start: uppercase
- parameters or variables start: lowercase
- constants (later): all uppercase
- use uppercase to start multi-part words (not _)