home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / c / c_plus_tut / cpp / scopeop < prev    next >
Encoding:
Text File  |  1994-04-05  |  593 b   |  30 lines

  1.                                       // Chapter 1 - Program 2
  2. #include "iostream.h"
  3.  
  4. int index = 13;
  5.  
  6. main()
  7. {
  8. float index = 3.1415;
  9.  
  10.    cout << "The local index value is " << index << "\n";
  11.    cout << "The global index value is " << ::index << "\n";
  12.  
  13.    ::index = index + 7;  // 3 + 7 should result in 10
  14.  
  15.    cout << "The local index value is " << index << "\n";
  16.    cout << "The global index value is " << ::index << "\n";
  17.  
  18. }
  19.  
  20.  
  21.  
  22.  
  23. // Result of execution
  24. //
  25. // The local index value is 3.1415
  26. // The global index value is 13
  27. // The local index value is 3.1415
  28. // The global index value is 10
  29.  
  30.