C++ 错误:`class`中的`MEMBER`未命名类型;C++;

C++ 错误:`class`中的`MEMBER`未命名类型;C++;,c++,gcc,sfml,C++,Gcc,Sfml,嘿,我已经构建了一个类来存储一些信息作为类的静态成员。 在编译时,我得到了一个错误: 错误:“类配置”中的“cubeLength”未命名类型 错误:“类配置”中的“cellColor”未命名类型 Config.h的内容 #ifndef CONFIG_H #define CONFIG_H #include <SFML/Graphics.hpp> class Config { public: static float cubeLength ; static

嘿,我已经构建了一个类来存储一些信息作为类的静态成员。 在编译时,我得到了一个错误:

错误:“类配置”中的“cubeLength”未命名类型

错误:“类配置”中的“cellColor”未命名类型

Config.h的内容

#ifndef CONFIG_H
#define CONFIG_H

#include <SFML/Graphics.hpp>

class Config {
public: 
    static float     cubeLength ;
    static sf::Color cellColor;
private:
    Config();
    Config(const Config& orig);
};

Config::cubeLength = 10.f; //error thrown here
Config::cellColor  = sf::Color::Magenta;  //error thrown here


#endif  /* CONFIG_H */
\ifndef配置
#定义配置
#包括
类配置{
公众:
静态浮体立方长度;
静态sf::颜色细胞颜色;
私人:
Config();
配置(const-Config和orig);
};
Config::cubeLength=10.f//此处抛出错误
配置::cellColor=sf::颜色::洋红色//此处抛出错误
#endif/*配置*/
我正在Linux上使用GNU编译器。
请帮助我解决此问题,因为错误说明您需要在减速中包含类型信息。您需要:

float Config::cubeLength = 10.f;
sf::Color Config::cellColor = sf::Color::Magenta;

执行赋值时,这些变量的类型信息丢失

这应该可以解决这个问题:

static float Config::cubeLength = 10.f;
static sf::Color Config::cellColor = sf::Color::Magenta;

就这样,你是我的英雄:)