CPS 6, Ramm - Spring 2000 - 1/14/00 #2
- Announce
- Roll
- Lab #1 (starts next week!)
- Assignment #1
Chapter 2: C++ Programs: Form and Function
- Sample Function Call
rainf.cpp
- Functions: Dia & Mond
diamond.cpp
tree.cpp
- Flow of Control
- Output, Stream 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.cpp
What is evaluated? What is not?
- 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.cpp
page.cpp
- Functions with several parameters
announce.cpp
Order of Parameters
- Functions Invoking Functions
diamond2.cpp
- Order of Functions
mondias.cpp
- Function Prototypes - Syntax
return-type
function(type name, type name, ...);
return-type
function(type, type, ...);
===>>> ;
- Using Function Prototypes
diamondsp.cpp