域解析運算子:: 真不知道該怎麼形容它螞蟻書也寫得很玄,不如直接看範例,在main()中print number會顯示10.5如果想要使用global number就必須使用::解析域運算元去指定現在要使用的命名空間,反正就是這樣。
// Fig. 6.23: fig06_23.cpp
// Using the unary scope resolution operator.
#include <iostream>
using std::cout;
using std::endl;
int number = 7; // global variable named number
int main()
{
double number = 10.5; // local variable named number
// display values of local and global variables
cout << "Local double value of number = " << number
<< "\nGlobal int value of number = " << ::number << endl;
return 0; // indicates successful termination
} // end main
void set_varible(){
short number = 7
}