TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALL
from: CARLTON WALTERS
date: 1998-02-08 22:21:00
subject: I need a litte explanation

/*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)

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™.