C ++ - 编译错误

时间:2014-05-24 12:30:39

标签: c++ compilation

我正在尝试编译以下程序,但它无法正常工作,我不知道为什么。 编译器不知道Player.hh中定义的Player类

Update.cpp:19:39: error: expected type-specifier before ‘Player’
Graphic/Update.cpp:19:39: error: expected ‘>’ before ‘Player’
Graphic/Update.cpp:19:39: error: expected ‘(’ before ‘Player’
Graphic/Update.cpp:19:47: error: expected primary-expression before ‘>’ token
Graphic/Update.cpp:19:67: error: expected ‘)’ before ‘;’ token
make: *** [Graphic/Update.o] Error 1

我的代码(.cpp):

#include "Player.hh"
#include "Update.hh"

Update::Update()
{
  creator[NOTHING] = &Update::Nothing;
  creator[WALLFIX] = &Update::Wallfix;
  creator[WALLBRK] = &Update::Wallbrk;
  creator[PLAYER] = &Update::Player;
  creator[AI] = &Update::Ai;
}

Update::~Update()
{
}

bool          Update::init_map(std::vector<AObject *> &objects, Map &map, const std::vector<IElements *> &players)
{
  Player      *player = (dynamic_cast<Player *> (players.front())); // this line cause the error

 (void)map;
 for (int i = (player->getY() - 10); i < player->getY() + 10; ++i)
 for (int j = (player->getX() - 10); j < player->getX() + 10; ++j)
      {
        AObject *obj;

        if ((obj = (this->*creator[NOTHING])(i, j)) == NULL)
          return false;
        objects.push_back(obj);
      }
  return true;
}

Player.hh文件继承自抽象类ABro.hh

#ifndef PLAYER_HH_
# define PLAYER_HH_

# include "ABro.hh"

class Player
  : public ABro
{
public:
  Player(TypeElements elem);
  ~Player();
  Player(Player const & other);
  Player & operator=(Player const & other);
};

#endif /* !PLAYER_HH_ */

0 个答案:

没有答案