如何在不干扰全局声明段的现有头文件的情况下创建具有相同功能的相同结构/变量?全局变量段(Main.cpp)列在标题代码
下面请注意 - 我不允许编辑头文件以使其具有noEntry / Explorable(特殊情况)
HEADER CODE
struct PathFinderResource
{
pthread_t activeThreadArray [MAX_NO_OF_THREADS];
PathFinderParameterInfo * activeThreadParamArray [MAX_NO_OF_THREADS];
VectorOfPointStructType solutionPath;
VectorOfPointStructType discoveredDangerAreas;
//VectorOfPointStructType noEntry;
//VectorOfPointStructType explorable;
int usedThreadNameIndex;
int noOfDeadEndPathsFound;
int noOfBarriersDiscovered;
int noOfDangerAreaDiscovered;
PathFinderResource (void)
{
usedThreadNameIndex = 0;
noOfDeadEndPathsFound = 0;
noOfBarriersDiscovered = 0;
noOfDangerAreaDiscovered = 0;
solutionPath = VectorOfPointStructType ();
discoveredDangerAreas = VectorOfPointStructType ();
}
~PathFinderResource (void)
{
solutionPath.clear ();
discoveredDangerAreas.clear ();
}
};
PathFinderResource globalPathFinderResource;
的main.cpp 这些是我尝试解决以下错误的各种尝试
Assn3.cpp:311:42:错误:'struct Assignm3 :: PathFinderResource'没有名为'noEntry'的成员 globalPathFinderResource.noEntry.push_back(nextPoint); ^ Assn3.cpp:在函数'VectorOfPointStructType findAlternativePath(VectorOfPointStructType)'中: Assn3.cpp:347:35:错误:'struct Assignm3 :: PathFinderResource'没有名为'explorable'的成员 if(!globalPathFinderResource.explorable.empty()) ^ Assn3.cpp:349:43:错误:'struct Assignm3 :: PathFinderResource'没有名为'explorable'的成员 for(j = globalPathFinderResource.explorable.rbegin(); j< globalPathFinderResource.explorable.rend(); j ++)
// Global Variables
const std::string filename = "mazedata.txt";
globalPathFinderResource noEntry = VectoryOfPointStructType();
globalPathFinderResource explorable = VectoryOfPointStructType();
//VectorOfPointStructType noEntry = VectorOfPointStructType ();
//VectorOfPointStructType explorable = VectorOfPointStructType ();
//globalPathFinderResource VectorOfPointStructType noEntry = VectorOfPointStructType();
//globalPathFinderResource VectorOfPointStructType explorable = VectorOfPointStructType();