主页
C++
C++ 变量作用域
demo_scope_global3
运行 ❯
×
更改方向
保存代码
更改主题
#include
using namespace std; // Global variable x int x = 5; void myFunction() { cout << ++x << "\n"; // Increment the value of x by 1 and print it } int main() { myFunction(); cout << x; // Print the global variable x return 0; }
6
6