// C2_7.cpp : Defines the entry point for the console application. // 變數範圍的驗証 #include "stdafx.h" #include using namespace std; int main(int argc, char* argv[]) { int value1 = 11; // 宣告變數 int value3 = 33; cout << endl << "範圍外的 = " << value1 << endl; { // 新範圍開始 int value1 = 112; // 其他的 value1 int value2 = 222; cout << "範圍內的 value1 = " << value1 << endl; value1 += 6; // 將影響內部的 value1 value3 += value2; } // 範圍結束 cout << endl <<"範圍外的 value1 = " << value1 << endl << "範圍外的 value3 = " << value3 << endl; return 0; }