我聲明我的結構對象在我的類中的私有,我初始化他們使用的構造函數,但我的風格檢查說我的結構類型的成員函數不被初始化。在這方面,任何人都可以幫助我,我會非常感謝你。初始化結構對象++
下面是我的代碼,請提出一些解決這個問題
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