我试图创建一个指针列表,让我可以访问所有创建的对象。
typedef struct global {
int gameEntityCount;
Entity* gameEntities[]; // Line 17
int nextValidSpot();
} global;
1>Entity.cpp 1>d:\source\repos\game\maybegame\game.h(17): error C2143: syntax error: missing ';' before '*' 1>d:\source\repos\game\maybegame\game.h(17): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>d:\source\repos\game\maybegame\game.h(17): error C2238: unexpected token(s) preceding ';'
有人能帮忙吗?
在此处初始化:
Map::Map()
{
// Initialize global
gameGlobal = new global();
// Set map id (always 0) and address (to get pointer later on)
m_iEnt = 0;
gameGlobal->gameEntities[m_iEnt] = &m_pEnt;
m_szClassname = "map";
// Increase count to allow other entities to come in
gameGlobal->gameEntityCount++;
std::cout << "Constructor Map";
}
1条答案
按热度按时间tnkciper1#
你真的应该
在c++中有很多复杂的东西,但是你必须知道,字符串,向量,Map,列表,shared_ptr和unique_ptr