PracticeDev/study_cpp/cpp_primer_source_code/Chapter 9/external.cpp

22 lines
663 B
C++
Raw Normal View History

2022-12-20 17:31:11 +08:00
// external.cpp -- external variable
// compile with support.cpp
#include <iostream>
// external variable
double warming = 0.3; // warming defined
// function prototypes
void update(double dt);
void local();
int main() // uses global variable
{
using namespace std;
cout << "Global warming is " << warming << " degrees.\n";
update(0.1); // call function to change warming
cout << "Global warming is " << warming << " degrees.\n";
local(); // call function with local warming
cout << "Global warming is " << warming << " degrees.\n";
// cin.get();
return 0;
}