标签:turn namespace c++ prime 技术 end return code 技术分享 输出
1 #include <iostream> 2 using namespace std; 3 4 class c1 5 { 6 public: 7 int a; 8 void foo(); 9 class c2 10 { 11 public: 12 int a; 13 void foo(); 14 } b; 15 }; 16 void c1::foo() 17 { 18 a = 1; 19 } 20 void c1::c2::foo() 21 { 22 a = 2; 23 } 24 25 int main() 26 { 27 28 class c1 f; 29 f.foo(); 30 f.b.foo(); 31 cout << f.a << endl; 32 cout << f.b.a << endl; 33 return 0; 34 }
输出结果:
标签:turn namespace c++ prime 技术 end return code 技术分享 输出
原文地址:https://www.cnblogs.com/sunbines/p/9543669.html