我有一个程序在构建失败后在编译器控制台中输出以下内容:
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";
主.cpp:
#include <iostream>
#include "Config.h"
#include "Display.h"
int main(int argc, char *argv[]) {
return 0;
}
有人可以解释为什么我的程序输出上述错误吗?
感谢您的时间。