home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / tutorial / cpptutor / source / scopeop.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-15  |  632 b   |  29 lines

  1.                                // Chapter 1 - Program 2 - SCOPEOP.CPP
  2. #include <iostream.h>
  3.  
  4. int index = 13;
  5.  
  6. void 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. // Result of execution
  23. //
  24. // The local index value is 3.1415
  25. // The global index value is 13
  26. // The local index value is 3.1415
  27. // The global index value is 10
  28.  
  29.