// Exception.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> using namespace std; namespace blip { int bi=16; int bj=15; int bk=23; } int bj=0; namespace A { int i; namespace B { int i; int j; int f1() { int j; return i; } } int f2() { return i; } int j=i; } int _tmain(int argc, _TCHAR* argv[]) { int i=0; try { i=1000000000000000000; } catch(exception) { cout<<"数据错误!"<<endl; } using namespace blip; ++bi;//blip::bi ++::bj;//int bj ++blip::bj; int bk=97; cout<<"the value of bi is "<<bi<<endl; cout<<"the value of globle bj is "<<::bj<<endl; cout<<"spacename bj="<<blip::bj<<endl; cout<<"the value of bk is "<<bk<<endl; A::i=10; i++;//int i; A::B::i++; int t=A::B::f1(); cout<<"A::i is "<<A::i<<endl; cout<<"A::B::i is "<<A::B::i<<endl; system("pause"); return 0; } 结果显示如下