/*Program Name: SCOPE.CPP
Created By : Carlton Walters
Date : Wednesday February 4, 1998
Revision : 0
This program Demonstrates the scope resolution operator.
*/
#include
#include
int k = 100; // Global variable
main()
{ int i = 200; //local variable to main
clrscr();
cout <<"Global k == " << k << '\n';
cout <<"Local i == " << i << "\n";
int k = 400; // local variable to main
{ int k = 300; //local block scope variable inside main
cout << "Local k == " << k << '\n';
cout << "Global k == " << ::k << '\n'; // display 100
// but if :: refers to the outer
//scope should it not display 400 ?
}
return 0;
}---
---------------
* Origin: House of Fire BBS - Toronto - (416)601-0085 - v.34 (1:250/536)
|