|
CMPT 212
Spring 1998
|
int * pInt = new int; char * pChar = NULL; pChar = new char;
delete pInt; pInt = NULL; delete pChar; pChar = NULL;
float * pArray = new float[10]; ... delete [] pArray;
void f(char c) {
float g = 3.0;
for (int i = 0; i < 10; i++) {
int j;
j = i;
cout << j;
}
cout << g;
return;
}
g exists for the entire function, and i
and j exist only in the loop.
void f(int x) {
static int count = 0;
count++;
cout << "f has been called " << count << " times.";
...
return;
}
count exists for the duration of the
program, although its scope is just the function
f.
Return to lecture notes index |
|
| This page is maintained by simpson@cs.sfu.ca. | Last updated on 26 Jan 1998. |