
Lesson 9-2: Static and Automatic Variables
Scope, Lifetime, and More on Functions | 211
Name __________________________________________ Date _______________________
Section _________________________________________
Use program Differences for Exercises 1 and 2.
// Program Differences is for investigating the differences
// between automatic and static variables.
#include <iostream>
using namespace std;
void TestLocals();
int main ()
{
TestLocals();
TestLocals();
TestLocals();
return 0;
}
// ***************************************
void TestLocals()
{
/* TO BE FILLED IN */
}
Exercise 1: Function TestLocals defines a local variable, count, and initializes it to 1. ...