非const的变量,默认为 extern ,可以在其他文件中访问
      而要使const变量能够在其他文件中访问,必须显式指定它为 extern ;

      //file_1.cpp
      extern const int CONST_SIZE = 10;
      //file_2.cpp
      extern const int CONST_SIZE;
      int i = CONST_SIZE;

相关文章:

  • 2021-12-29
  • 2021-09-05
  • 2021-05-17
  • 2021-07-28
  • 2021-07-19
  • 2021-08-17
  • 2021-04-18
猜你喜欢
  • 2021-08-29
  • 2021-12-03
  • 2021-09-19
  • 2021-04-04
  • 2021-08-13
  • 2022-12-23
  • 2022-01-07
相关资源
相似解决方案