错误:“ cast”没有将类型命名为void setCastDescription(std :: string desc)cast.description = desc; }

时间:2018-09-01 13:50:28

标签: c++ error-code

player.h:155:43: error: expected ‘;’ at end of member declaration
   void setCastDescription(std::string desc) cast.description = desc; }

player.h:155:45: error: ‘cast’ does not name a type
   void setCastDescription(std::string desc) cast.description = desc; }

player.h: In member function ‘bool Player::getCastingState() const’:
player.h:148:39: error: ‘cast’ was not declared in this scope
  bool getCastingState() const {return cast.isCasting; };
                                       ^

player.h: In member function ‘virtual const string& Player::getCastingPassword() const’:
player.h:149:65: error: ‘cast’ was not declared in this scope
  virtual const std::string & getCastingPassword() const {return cast.password; };
                                                                 ^

player.h: In member function ‘PlayerCast Player::getCast()’:
player.h:150:31: error: ‘cast’ was not declared in this scope
  PlayerCast getCast() {return cast; }
                               ^

player.h: In member function ‘void Player::setCastPassword(std::string)’:
player.h:153:39: error: ‘cast’ was not declared in this scope
  void setCastPassword(std::string p) {cast.password = p; };
                                       ^

player.h: At global scope:
player.h:156:28: error: expected initializer before ‘&’ token
  virtual const std::string & getCastDescription() const return cast.description; }
                            ^

player.h:156:82: error: expected declaration before ‘}’ token
  virtual const std::string & getCastDescription() const return cast.description; }
                                                                                  ^

这是我正在尝试编译的代码..它非常大,因此我只会在出现错误的地方发布代码...

bool getCastingState() const {return cast.isCasting; };
virtual const std::string & getCastingPassword() const {return cast.password; };
PlayerCast getCast() {return cast; }

void setCasting(bool c);
void setCastPassword(std::string p) {cast.password = p; };

void setCastDescription(std::string desc) cast.description = desc; }
virtual const std::string & getCastDescription() const return cast.description; }

我已经在所有地方进行搜索以找到类似的东西,但是自昨天以来我什么也没得到,我正试图找出解决方案,希望这里有人可以帮助我

1 个答案:

答案 0 :(得分:2)

您缺少演员表说明的获取器和安装器的左括号:

void setCastDescription(std::string desc) cast.description = desc; }
                                          ^
virtual const std::string & getCastDescription() const return cast.description; }
                                                       ^