VS里的绿色波浪线需不需要修改?
程序代码:
#include<iostream> #include<string> using namespace std; struct Jg{string Xingming; double Qian;}; int main() { int Zongshu; cout << "总共有多少名捐赠者?"; cin >> Zongshu; cin.get(); Jg* a = new Jg[Zongshu]; for (int i = 0; i < Zongshu; i++) { cout << "请输入捐赠者姓名:"; getline(cin, a[i].Xingming); cout << "请输入捐赠金额(单位/元):"; cin >> a[i].Qian; cin.get(); } bool You_1 = false; bool You_2 = false; cout << "Grand Patrons:" << endl; for (int i = 0; i < Zongshu; i++) if (a[i].Qian > 10000) { cout << "姓名:" << a[i].Xingming << endl; cout << "金额:" << a[i].Qian << endl; You_1 = true; } if (You_1 == false)cout << "none" << endl; cout << "Patrons:" << endl; for (int i = 0; i < Zongshu; i++) if (a[i].Qian < 10000) { cout << "姓名:" << a[i].Xingming << endl; cout << "金额:" << a[i].Qian << endl; You_2 = true; } if(You_2==false)cout << "none" << endl; delete [] a; system("pause"); return 0; }
在第4行代码struct Jg{string Xingming; double Qian;};有绿色波浪,提示为未初始化变量 Jg::Qian。始终初始化成员变量(type.6)。
程序能正常运行,想问下这个提示是什么意思,是说我没给Qian这个变量赋值么?一般什么情况下会出现这种现象?