-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto.cpp
40 lines (36 loc) · 962 Bytes
/
auto.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// auto.cpp -- illustrating scope of automatic variables
#include <iostream>
using namespace std;
void oil(int x);
int main()
{
int texas = 31;
int year = 1999;
cout << "In main(), texas = " << texas << ", &texas = ";
cout << &texas << endl;
cout << "In main(), year = " << year << ", &year = ";
cout << & year << endl;
oil(texas);
cout << "In main(), texas = " << texas << ", & texas = ";
cout << &texas << endl;
cout << "In main(), year = " << year << ", &year = ";
cout << &year << endl;
return 0;
}
void oil(int x)
{
int texas = 5;
cout << "In oil(), texas = " << texas << ", &texas = ";
cout << &texas << endl;
cout << "In oil(), x = " << x << ", &x = ";
cout << &x << endl;
{
int texas = 113;
cout << "In block, texas = " << texas;
cout << ", &texas = " << &texas << endl;
cout << "In block, x = " << x << ", &x = ";
cout << &x << endl;
}
cout << "Post-block texas = " << texas;
cout << ", &texas = " << &texas << endl;
}