错误:'cast'没有命名类型void setCastDescription(std :: string desc)cast.description = desc; } [关闭]

问题描述 投票:-3回答:1
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; }

我已经到处搜索找到类似的东西,但我从昨天起没有得到任何东西我想找到一个解决方案,我希望有人在这里可以帮助我

c++ error-code
1个回答
2
投票

您缺少对演员说明的getter和setter的左括号:

void setCastDescription(std::string desc) cast.description = desc; }
                                          ^
virtual const std::string & getCastDescription() const return cast.description; }
                                                       ^
© www.soinside.com 2019 - 2024. All rights reserved.