1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| #include<iostream>
using namespace std;
namespace xiaochenyanA { int a; }
namespace xiaochenyanB { int a;
namespace xiaochenyanC { typedef struct student { float score; }student_t; } namespace xiaochenyanD { typedef struct student { double score; }student_t; } using namespace xiaochenyanC; }
int main(int argc, char* argv[]) { using namespace xiaochenyanA; using namespace xiaochenyanB; using namespace xiaochenyanB::xiaochenyanC;
student_t xiaoming = { 100.0f }; cout << xiaoming.score << endl; cout << (xiaochenyanA::a = 100) << endl; cout << xiaochenyanA::a << endl; cout << xiaochenyanB::a << endl; cin.get(); return 0; }
|