10.static_extern

  • 另一个文件声明
    #include <iostream>
    using namespace std;
    int x = 10;
    
    void show()
    {
        cout << "1234" << endl;
    }
  • 本文件使用
     1 #include <iostream>
     2 using namespace std;
     3 //引用外部全局变量
     4 extern int x;
     5 
     6 //只能在当前文件使用
     7 static int x1 = 100;
     8 
     9 void show();
    10 
    11 void main()
    12 {
    13     cout << x << endl;
    14     show();
    15     cin.get();
    16 }
原文地址:https://www.cnblogs.com/xiaochi/p/8543773.html