我是靠谱客的博主 儒雅香烟,这篇文章主要介绍compile time constant 编译时常量,现在分享给大家,希望可以做个参考。

头文件test.h中添加

复制代码
1
2
extern const int a;

cpp文件test.cpp中添加

复制代码
1
2
3
#include "test.h" const int a = 0;

main.cpp

复制代码
1
2
3
4
5
6
7
#include "test.h" int main() { a; }

编译时a不是一个编译时常量,main.cpp有可能先编译,此时a未定义会产生报错。

最后

以上就是儒雅香烟最近收集整理的关于compile time constant 编译时常量的全部内容,更多相关compile内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(87)

评论列表共有 0 条评论

立即
投稿
返回
顶部