CW> int k = 100; // Global variable
CW> main()
CW> {
CW> int k = 400; // local variable to main
CW> { int k = 300; //local block scope variable inside main
CW> cout << "Global k == " << ::k << '\n'; // display 100
CW> // but if :: refers to the outer
CW> //scope should it not display 400 ?
CW> }
CW> return 0;
CW> }
If ::k meant the previous scope, how would you refer to the global variable?
::::k? As you can see, we're only going to be able to access one at a time
anyway, so we can be quite a bit more consistant (making it easier to follow)
by having "::" refer to the global version of instead of just
the previous scope.
---
---------------
* Origin: Tanktalus' Tower BBS (1:250/102)
|