a300visi.cpp

来自「secondo esempi vari per c++ (schema base」· C++ 代码 · 共 38 行

CPP
38
字号
// nuovi concetti: variabile globale, ambiti di visibilita'
#include <iostream>

using namespace std;

void f();
void g();
int x = 11;

int main()
{
  int x = 22;
  {
    int x = 33;
    cout << "Nel blocco interno a main(): x = " << x << endl;
  }
  cout << "In main(): x = " << x << endl;
  f();
  g();
}

void f() {
  int x = 44;
  cout << "In f(): x = " << x << endl;
}

void g() {
  cout << "In g(): x = " << x << endl;
}

/* Output:
Nel blocco interno a main(): x = 33
In main(): x = 22
In f(): x = 44
In g(): x = 11
*/

⌨️ 快捷键说明

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