Brief
The goal of this lesson is to get everyone better familiar with creating functions and how to use incremental development (aka Divide and Conquer) using test harnesses.
Outline
- [0-10 min] Q & A
- [5-10 min] Go over today's quiz
- [10 min] Mini-Quiz
- [Break up the following code into separate functions]
int main()
{
int input1 = prompt("Enter a number: "),
input2 = prompt("Enter another number: ");
// Limit input1 between 5 and 9
if (input1 < 5)
input1 = 5;
else if (input1 > 9)
input1 = 9;
// Limit input2 between 3 and 7
if (input2 < 3)
input2 = 3;
else if (input2 > 7)
input2 = 7;
return 0;
}
- [10-15 min] Review of Functions
- Syntax
- Forward Declarations
- Overloading
- Reference Parameters
- Compositions
- [5-10 min] Constants
- Global Constant Variables vs. Global Variables
- [10-20 min] Incremental Development (Divide and Conquer)
- Test Harnesses
- [5-10 min] Review of Scoping
- int foo()
{
int x = 3;
return x;
}
int bar()
{
int y = 5;
return y;
}
int main()
{
int x = bar();
int q = foo();
cout << x << q;
return 0;
}
- [5-10 min] Review of Dot Operator
- Member Functions
No comments:
Post a Comment