CPS 6, Ramm - Summer Semester I - 5/21/99 #2
- Announce
- Random Quiz #1
- Assignment #1 (Due 11:59pm May 26)
Chapter 2: C++ Programs: Form and Function
- Sample Function Call
rainf.cc
- Functions: Dia & Mond
diamond.cc
tree.cc
- Flow of Control
- Output, Insertion Operator
<<
- Literals: string, integer, real, expressions
cout << "product = " << "12" << endl;
cout << "product = " << 12 << endl;
cout << "product = " << "3 * 4" << endl;
cout << "product = " << 3 * 4 << endl;
literals.cc
- Syntax/Grammar
- Semantics/Meaning
- Some C++ Syntax Rules
- Start with
#include statements
- Follow with user-defined functions (if any)
- Must have
int main() function
- Case is Important
- (more to come)
- Style (Important!)
- Functions with Parameters
Flexibility/Versatility
rect5by.cc
page.cc
- Functions with several parameters
announce.cc
Order of Parameters
- Functions Invoking Functions
diamond2.cc
- Order of Functions
mondias.cc
- Function Prototypes - Syntax
return-type
function(type name, type name, ...);
return-type
function(type, type, ...);
===>>> ;
- Using Function Prototypes
diamondsp.cc