C++ C++;调用默认复制构造函数时程序崩溃

C++ C++;调用默认复制构造函数时程序崩溃,c++,pointers,crash,copy-constructor,C++,Pointers,Crash,Copy Constructor,我正在编写一个map类,它从XML文档中读取信息并构建一个map对象。地图首先从XML文件读取磁贴类型定义,并将其存储在地图中,通过其ID索引每个磁贴的信息。然后,它读取另一个包含地图景观信息(磁贴坐标等)的文件,并尝试填充磁贴数组 是这样的: class TileInfo { //Information about tile stats, bitmaps, movement cost etc }; class Tile { TileInfo* info; vect

我正在编写一个map类,它从XML文档中读取信息并构建一个map对象。地图首先从XML文件读取磁贴类型定义,并将其存储在地图中,通过其ID索引每个磁贴的信息。然后,它读取另一个包含地图景观信息(磁贴坐标等)的文件,并尝试填充磁贴数组

是这样的:

class TileInfo {
    //Information about tile stats, bitmaps, movement cost etc
};

class Tile {
     TileInfo* info;
     vector<TileInfo*> lastSeenByPlayer; //due to fow each player can be seeing different tiles since they haven't updated yet
     //other tile specific tile information like coordinates etc
public:
     Tile(int x, int y, TileInfo* info /*other parameters*/);
};

Tile::Tile(int x, int y, TileInfo* info /*...*/) {
     this->info = tileInfo;
     this->x = x;
     this->y = y;

     for(unsigned int i = 0; i < NUM_PLAYERS; i++)
          lastSeenByPlayer.push_back(info);
}

class GameMap {
     map<int,TileInfo> tileInformation;
     vector<vector<Tile>> tiles;

     Tile loadTile(int tileID, int x, int y);
     void loadTerrainFromFile(string filename);
};

Tile GameMap::loadTile(int tileID, int x, int y) {
     map<int,TileInfo>::iterator it = tileInformation.find(tileID);
     if( it!=tileInformation.end())
         TileInfo* info = &(it->second);
     else
         throw errorLoadingTile();

    return Tile(x,y,info /*other information*/);
}

void GameMap::loadTerrainFromFile(string filename) {
     //open file and read information
     //at this point the GameMap already has the map with the tile information filled
     //from when it was created

     for(unsigned int x = 0; x < mapWidth; x++)
         for(unsigned int y = 0; y < mapHeight; y++) {
              cout << "Works up to here" << endl;
              tiles[y][x] = loadTile(tileIDs[x][y],x,y);
              cout << "Crashes before this" << endl;

         }

    //do more stuff
};
class-TileInfo{
//有关平铺统计信息、位图、移动成本等
};
类瓷砖{
TileInfo*信息;
vector lastSeenByPlayer;//由于fow,每个玩家可以看到不同的磁贴,因为它们尚未更新
//其他特定于磁贴的磁贴信息,如坐标等
公众:
平铺(intx、inty、TileInfo*info/*其他参数*/);
};
Tile::Tile(intx,inty,TileInfo*info/*…*/){
此->信息=tileInfo;
这个->x=x;
这->y=y;
对于(无符号整数i=0;i秒);
其他的
抛出ErrorLoadingFile();
返回磁砖(x、y、信息/*其他信息*/);
}
void GameMap::LoadTerrainFomFile(字符串文件名){
//打开文件并读取信息
//此时游戏地图已经填充了平铺信息
//从它创建时开始
for(无符号整数x=0;x无法尝试调试该问题。调试器应在崩溃处停止。然后发布结果。它是否实际编译?在“GameMap::loadTile”中,您在if中分配了
TileInfo*info=
,可能您正在传递到“return Tile(x,y,info/*其他信息*/)`其他一些空信息?我发现了。伙计们。我是个弱智-。-,我把平铺改成了向量向量,忘了把赋值改成推回。谢谢你的回答,我会把平铺信息*信息声明改成不在if上。@user2302419:好的,也许你想写下你自己的答案,然后接受它,这样人们就不会再这样做了阅读你的问题并尝试解决你的问题。