home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c031 / 4.ddi / SAMPLES / CPPTUTOR / VARDECL.CP$ / VARDECL
Encoding:
Text File  |  1991-12-12  |  489 b   |  20 lines

  1. // VARDECL.CPP
  2.  
  3. // This is an example program from Chapter 2 of the C++ Tutorial. This
  4. //     program demonstrates the placement of variable declarations.
  5.  
  6. #include <iostream.h>
  7.  
  8. void main()
  9. {
  10.    for( int lineno = 0; lineno < 3; lineno++ )
  11.    {
  12.        int temp = 22;
  13.        cout << "This is line number " << lineno
  14.             << " and temp is " << temp << '\n';
  15.    }
  16.    if( lineno == 4 )   // lineno still accessible
  17.        cout << "Oops\n";
  18.    // Cannot access temp
  19. }
  20.