⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex0218.cpp

📁 《C++编程习题与解答》书中所有例题与习题的源代码
💻 CPP
字号:
//  Programming with C++, Second Edition, by John R. Hubbard
//  Copyright McGraw-Hill, 1999
//  Example 2.18 on page 31
//  Scope of Variables

#include <iostream>
using namespace std;

int main()
{ // illustrates the scope of variables:
  x = 11;    // ERROR: this is not in the scope of x
  int x;
  { x = 22;  // OK: this is in the scope of x
    y = 33;  // ERROR: this is not in the scope of y
    int y;
    x = 44;  // OK: this is in the scope of x
    y = 55;  // OK: this is in the scope of y
  }
  x = 66;    // OK: this is in the scope of x
  y = 77;    // ERROR: this is not in the scope of y
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -