2
我想让对象引用一些全局变量(在开始使用全局变量将它们放入对象之前将使它无法被其他对象访问,或者需要向方法调用中添加多余的参数)例如解析为全局
的main.cpp
bool firstLoop;
const int dt = 10;
thing.cpp
void thing::Update(Object * thingToUpdate){
if(firstLoop){
...
} else{
// working with dt
}
}
但每次我尝试访问的变量时,我得到“U的错误ndeclared标识符“ 我需要将它们标记为extern或其他东西吗?
我需要把它放到每个使用指定变量的文件中 – gardian06 2012-02-02 13:56:59
@ gardian06:是的,你这样做。查看我的更新 – 2012-02-02 14:03:04