2
我已完成編寫一個程序,您可以輸入20個學生的成績,並計算出他們的平均數以及總測試平均數。但是,雖然它編譯並運行,但我得到以下警告:成員初始化列表?合成方法?結構/數組編譯問題
In constructor 'student::student()':
warning: 'student::name' should be initialized in the member initialization list
note: synthesized method 'student::student()' first required here
這是什麼原因導致的?我假設它值得注意和修復,那麼我將如何修復它?我已經包括了我認爲是代碼審查的相關部分:
#include <iostream>
#include <string>
using namespace std;
struct student
{ // The first warning is for this line
string name;
double testGrade[5];
};
student theStudent[20]; // The second warning is for this line
我很感謝您能爲我提供的任何幫助。
你使用什麼編譯器? – juanchopanza 2012-04-17 17:19:16
我正在使用Code :: Blocks和GNU GCC編譯器。 – quasipsychotic 2012-04-17 17:20:38
可能是GCC的一個非常舊的版本?當然,關於'name'的警告是錯誤的。我沒有用gcc 4.6或4.7。 – juanchopanza 2012-04-17 17:21:32