访问翻译单位的const变量

fre*_*low 2 c++ variables scope module const

在C++中,const变量隐式地隐藏在其他翻译单元中.有可能阻止吗?

Tro*_*our 7

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

extern const int x = 10;
Run Code Online (Sandbox Code Playgroud)