首页 > 试题广场 >

下面的代码将显示什么内容? #include usin

[问答题]
下面的代码将显示什么内容?
#include <iostream>
using namespace std;
void other();
namespace n1
{
int x = 1;
}
 
namespace n2
{
int x = 2;
}
 
int main()
{
using namespace n
cout << x << endl;
{
int x = 4;
cout<<x<<”,”<<n1::x<<”,”<<n2::x<<endl;
}
using n2::x;
cout<<x<<endl;
other();
return 0;
}
 
void other()
{
using namespace n2;
cout <<x<<endl;
(
int x = 4;
cout<<x<<”,”<<n1::x<<”,”<<n2::x<<endl;
}
using n2::x;
cout << x << endl;
}

1
4,1,2
2

2,
4,1,2
2
发表于 2017-12-27 20:15:21 回复(0)