zhangdingqu
 1 #include <iostream>
 2 using namespace std;
 3 
 4 namespace spaceA{
 5     int g_a = 10;
 6     namespace spaceB{
 7         //定义一个结构体
 8         struct teacher{
 9             int id;
10             char name[64];
11         };
12         //结构体定义结束
13 }
14 
15 }
16 using namespace spaceA;
17 int main(){
18     cout << "hello word!" << endl;
19     cout << g_a << endl;
20     //引用命名空间的结构体
21     using  spaceA::spaceB::teacher;
22     //实例化结构体,取名叫t1
23     struct teacher t1;
24     //使用结构体成员ID,并为其赋值100
25     t1.id = 100;
26     return 0;
27     
28 }

 

分类:

技术点:

相关文章:

  • 2021-10-16
  • 2022-12-23
  • 2021-11-23
  • 2021-05-19
  • 2022-01-12
  • 2021-10-16
  • 2021-07-09
  • 2022-12-23
猜你喜欢
  • 2021-10-16
  • 2021-10-16
  • 2021-12-25
  • 2021-10-16
  • 2021-10-16
  • 2021-07-21
  • 2021-09-13
相关资源
相似解决方案