调试器在命名空间中显示错误的静态int值 [英] Debugger shows wrong value for static int in a namespace
问题描述
你有一个带有静态int的命名空间
Hi have a namespace with a static int
命名空间ms
{
static int DISPLAY = 3;
static int DISPLAY = 3;
void run();
void setLevel(int lvl) ;
void run();
void setLevel(int lvl);
}
void run()
{
std :: cout< ;<显示<< std :: endl;
}
我将等级设置为4.运行"run"功能打印"4"。但是在调试VS"Autos"时窗口显示DISPLAY仍然具有值3.
为什么调试器错误?
void run()
{
std::cout << DISPLAY << std::endl;
}
I set the level to 4. Running the "run" function prints "4". But when debugging the VS "Autos" window shows that DISPLAY still has a value of 3.
Why is the debugger wrong?
推荐答案
你把断点放在哪里了?请确保哪个是当前上下文,"运行"&功能或"名称空间ms "?
参考主题: https://stackoverflow.com/a/18126643/9125096
Reference thread: https://stackoverflow.com/a/18126643/9125096
问候,
Fletcher
这篇关于调试器在命名空间中显示错误的静态int值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!