当我尝试构建我的 C++ 应用程序时,我得到了很多未解决的外部错误:
1>game.obj : error LNK2019: unresolved external symbol "public: __thiscall Player::Player(void)" (??0Player@@QAE@XZ) referenced in function "public: __thiscall Game::Game(void)" (??0Game@@QAE@XZ)
1>game.obj : error LNK2019: unresolved external symbol "public: __thiscall Player::Player(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Player@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: void __thiscall Game::newMonster(void)" (?newMonster@Game@@QAEXXZ)
1>game.obj : error LNK2019: unresolved external symbol "public: bool __thiscall Player::gameOver(void)" (?gameOver@Player@@QAE_NXZ) referenced in function "public: void __thiscall Game::defaultMenu(void)" (?defaultMenu@Game@@QAEXXZ)
1>game.obj : error LNK2019: unresolved external symbol "public: void __thiscall Player::updatePet(int,class Pet *)" (?updatePet@Player@@QAEXHPAVPet@@@Z) referenced in function "public: void __thiscall Game::inGameMenu(void)" (?inGameMenu@Game@@QAEXXZ)
1>game.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Player::enemyName(void)" (?enemyName@Player@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "public: void __thiscall Game::inGameMenu(void)" (?inGameMenu@Game@@QAEXXZ)
1>game.obj : error LNK2019: unresolved external symbol "public: class Pet * __thiscall Player::getMonster(int)" (?getMonster@Player@@QAEPAVPet@@H@Z) referenced in function "public: void __thiscall Game::inGameMenu(void)" (?inGameMenu@Game@@QAEXXZ)
1>game.obj : error LNK2019: unresolved external symbol "public: int __thiscall Player::getMonsterSize(void)" (?getMonsterSize@Player@@QAEHXZ) referenced in function "public: void __thiscall Game::inGameMenu(void)" (?inGameMenu@Game@@QAEXXZ)
1>game.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Player::getName(void)" (?getName@Player@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "public: void __thiscall Game::saveMonster(void)" (?saveMonster@Game@@QAEXXZ)
1>game.obj : error LNK2019: unresolved external symbol "public: void __thiscall Player::addMonster(class Pet *)" (?addMonster@Player@@QAEXPAVPet@@@Z) referenced in function "public: void __thiscall Game::loadMonster(void)" (?loadMonster@Game@@QAEXXZ)
1>game.obj : error LNK2019: unresolved external symbol "public: void __thiscall Player::setName(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?setName@Player@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: void __thiscall Game::loadMonster(void)" (?loadMonster@Game@@QAEXXZ)
1>fatal error LNK1120: 10 unresolved externals
问题是,这些错误几天前没有出现。他们只是突然冒出来的。
我还将我的 Player.h 包含在需要它的 Player.cpp 和 Game.cpp 中。
有人能帮我一下吗?