gpt4 book ai didi

c++ - 跨翻译单元访问 const 变量

转载 作者:太空狗 更新时间:2023-10-29 23:31:27 25 4
gpt4 key购买 nike

在 C++ 中,const 变量对其他翻译单元隐式隐藏。有可能避免这种情况吗?

最佳答案

是的,在定义前加上 extern 例如。

extern const int x = 10;

关于c++ - 跨翻译单元访问 const 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4690078/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com