我声明我的结构对象在我的类中的私有,我初始化他们使用的构造函数,但我的风格检查说我的结构类型的成员函数不被初始化。在这方面,任何人都可以帮助我,我会非常感谢你。初始化结构对象++
下面是我的代码,请提出一些解决这个问题
class Datastructure{
//forward decleration
struct Ship;
public:
//Constructor DS class
Datastructure();
//Destructor DS class
~Datastructure();
private:
struct Ship{
std::string s_class;
std::string name;
unsigned int length;
Ship();
Ship(const std::string& shipClass, const std::string& shipName,
unsigned int len);
};
Ship minShip;
Ship maxShip;
std::vector<Ship> shipVector;
};
#endif
它给我下面的警告
CIMP, line 17: Uninitialized member variables in class 'Datastructure'.
FSCH, line 17: No access specifiers at the beginning of class
'Datastructure'.
IVAP, line 62: Field 'minShip' in class 'Datastructure' is not initialized.
IVAP, line 63: Field 'maxShip' in class 'Datastructure' is not initialized.
IVAP, line 64: Field 'shipVector' in class 'Datastructure' is not
initialized.
哪个编译器正在使用哪些编译器选项?这些看起来像警告。你能运行你的代码吗? – 2010-10-03 15:54:57
您使用的是什么样式的检查器? 'Ship'和'std :: vector'都具有用户声明(对于用户的适当定义)构造函数,所以它们的任何实例都不可能保持未初始化。 – 2010-10-03 15:56:16