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

📄 ex2_06.cpp

📁 Beginning Visual C++ 6源码。Wrox。
💻 CPP
字号:
// EX2_06.CPP
// Demonstrating variable scope
#include <iostream>

using namespace std;

int main()
{                                         // Function scope starts here
   int count1 = 10;
   int count3 = 50;
   cout << endl
        << "Value of outer count1 = " << count1 
        << endl;

   {                                // New scope starts here...
      int count1 = 20;        // This hides the outer count1
      int count2 = 30;
      cout << "Value of inner count1 = " << count1
           << endl;
      count1 += 3;            // This affects the inner count1
      count3 += count2;
   }                                // ...and ends here

   cout << "Value of outer count1 = " << count1
        << endl
        << "Value of outer count3 = " << count3
        << endl;

   // cout << count2 << endl; // uncomment to get an error

   return 0;
}                                         // Function scope ends here

⌨️ 快捷键说明

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