gpt4 book ai didi

类中静态字符串的 C++ 奇怪编译器错误

转载 作者:行者123 更新时间:2023-11-30 04:24:48 25 4
gpt4 key购买 nike

<分区>

我有一个程序在构建失败后在编译器控制台中输出以下内容:

1>------ Build started: Project: BlackjackAttack, Configuration: Debug Win32 ------
1>Build started 9/18/2012 10:59:28 PM.
1>InitializeBuildStatus:
1> Touching "Debug\BlackjackAttack.unsuccessfulbuild".
1>ClCompile:
1> main.cpp
1>c:\bja\blackjackattack\config.h(5): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\bja\blackjackattack\config.h(5): error C2146: syntax error : missing ';' before identifier 'GAME_NAME'
1>c:\bja\blackjackattack\config.h(5): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> Display.cpp
1>c:\bja\blackjackattack\config.h(5): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\bja\blackjackattack\config.h(5): error C2146: syntax error : missing ';' before identifier 'GAME_NAME'
1>c:\bja\blackjackattack\config.h(5): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> Config.cpp
1>c:\bja\blackjackattack\config.h(5): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\bja\blackjackattack\config.h(5): error C2146: syntax error : missing ';' before identifier 'GAME_NAME'
1>c:\bja\blackjackattack\config.h(5): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\bja\blackjackattack\config.cpp(7): error C2039: 'GAME_NAME' : is not a member of 'Config'
1> c:\bja\blackjackattack\config.h(1) : see declaration of 'Config'
1> Generating Code...
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.32
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

配置.h:

class Config {
public:
static const int DEFAULT_CONSOLE_COLOR = 7;

static const string GAME_NAME;
};

配置.cpp:

#include <string>

#include "Config.h"

using std::string;

const string Config::GAME_NAME = "Name";

ma​​in.cpp:

#include <iostream>

#include "Config.h"
#include "Display.h"

int main(int argc, char *argv[]) {
return 0;
}

谁能解释一下为什么我的程序会输出上述错误?

感谢您的宝贵时间。

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