gpt4 book ai didi

c++ - 视觉 C++ : Compiler Error C4430

转载 作者:太空狗 更新时间:2023-10-29 23:23:01 25 4
gpt4 key购买 nike

Game.h代码:

#ifndef GAME_H
#define GAME_H

class Game
{
public:
const static string QUIT_GAME; // line 8
virtual void playGame() = 0;
};

#endif

错误:

game.h(8): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
game.h(8): error C2146: syntax error : missing ';' before identifier 'QUIT_GAME'
game.h(8): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

我做错了什么?

最佳答案

你需要做两件事:

  • #include <string>
  • 将类型更改为 const static std::string QUIT_GAME (添加 std:: )

关于c++ - 视觉 C++ : Compiler Error C4430,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2916691/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com