I have the following overloaded extraction operator function where I need to read values into an array. I keep on getting compile errors when I uncomment the: dayReport.dayOfMonth = dayP part. Could anyone point me to where I am going wrong. What I am trying to do is to read values from a file into an array.
[
istream& operator >> (istream& fin, weatherReport dayReport)
{
int dayP, highP, lowP, rainP, snowP, i;
i = 0;
cout << "Reading data from file..." << endl;
cout << left << setw(13)<< "Day #"
<< setw(13) << "High Temp"
<< setw(13) << "Low Temp"
<< setw(13) << "Rain"
<< setw(13) << "Snow" << endl
<< fixed << showpoint;
while(fin >> dayP >> highP >> lowP >> rainP >> snowP)
{
cout << left << setw(13) << dayP << setw(13) << highP
<< setw(13) << lowP << setw(13) << rainP << setw(13)
<< snowP << setw(13) << endl;
// dayReport[i].dayOfMonth = dayP;
i++;
}
]