mat*_*131 1 c++ global-variables
//main.cpp
#include <iostream>
#include "worldActions.h"
using namespace std;
bool worldEvents = false;
void worldReactions(bool world);
int main (int argc, const char * argv[])
{
while (true)
{
if (worldAction == true)
{
worldEvents = true;
worldReactions(worldEvents);
}
else
{
worldEvents = false;
break;
}
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
//1.cpp
#include <iostream>
#include "worldActions.h"
using namespace std;
bool worldAction;
Run Code Online (Sandbox Code Playgroud)
//头
#ifndef worldActions_h
#define worldActions_h
bool worldAction = true;
#endif /* defined(__asdf_Story__worldActions__) */
Run Code Online (Sandbox Code Playgroud)
当使用extern时我得到链接错误,当它不是我得到重新定义错误.我怎么能解决这个问题,所以我可以使用全局布尔值?
| 归档时间: |
|
| 查看次数: |
6083 次 |
| 最近记录: |