TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: CARLTON WALTERS
from: DARIN MCBRIDE
date: 1998-02-09 07:56:00
subject: I need a litte explanation

 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)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.