嘿,我已经构建了一个类来将一些信息存储为该类的静态成员。 在编译时我得到了错误:
error: ‘cubeLength’ in ‘class Config’ does not name a type
error: ‘cellColor’ in ‘class Config’ does not name a type
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 */
我在 Linux 上使用 GNU 编译器。 请帮帮我
最佳答案
如错误所述,您需要在减速中获得类型信息。您需要:
float Config::cubeLength = 10.f;
sf::Color Config::cellColor = sf::Color::Magenta;
关于c++ - 错误 : `MEMBER` in `class CLASS` does not name a type; C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28464430/