2012-04-17 60 views
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 

我很感谢您能为我提供的任何帮助。

+0

你使用什么编译器? – juanchopanza 2012-04-17 17:19:16

+0

我正在使用Code :: Blocks和GNU GCC编译器。 – quasipsychotic 2012-04-17 17:20:38

+0

可能是GCC的一个非常旧的版本?当然,关于'name'的警告是错误的。我没有用gcc 4.6或4.7。 – juanchopanza 2012-04-17 17:21:32

回答

2

你可以忽视这个警告是无稽之谈。你使用什么编译器/版本/标志?

+0

Code :: Blocks中的GNU GCC编译器。 – quasipsychotic 2012-04-17 17:21:13