I'm getting errors on lines 102, 115, and 128
. What am I doing wrong? It says:
Expected unqualified-id before numeric constant
and I don't know what that means. I've tried to fix this for a week now, and it's due in my C++ class this coming Wednesday. I could really use some outside advice here. What am I doing wrong:
#include <iostream>
#include <fstream>
#include <iomanip>
#include <conio.h>
#include <string>
using namespace std;
double qMeter = 0;
double hMeter = 0;
double oneMeter = 0;
int solDay = 0;
string garbage;
string localTime;
string decSol;
ifstream input;
ofstream output;
//function prototypes
double low(double lowTemp);
double high(double highTemp);
float average(double avgTemp);
int main()
{
input.open("curiosity234x.dat"); //opens input data file
output.open("output.dat"); //opens output data file
for (int i = 0; i < 4; i++) //gets rid of the first four lines
{
getline(input,garbage);
cout << endl;
}
while (!input.eof())
{
int count;
double newOneMeter;
double newHMeter;
double newQMeter;
if (solDay == 2) //processes data for the second solar day
{
input >> solDay >> localTime >> decSol
>> newOneMeter >> newHMeter >> newQMeter;
oneMeter = oneMeter + newOneMeter;
hMeter = hMeter + newHMeter;
qMeter = qMeter + newQMeter;
count++;
output << solDay << fixed << setprecision(1) << setw(5)
<< "Solar" << "Average" << "Low" << "High"
<< "Average" << "Low" << "High"
<< "Average" << "Low" << "High"
<< "Day" << "Temp" << "Temp" << "Temp" << "Temp" << "Temp"
<< "Temp" << "Temp" << "Temp" << "Temp"
<< fixed << setprecision(15) << "1 meter" << ".5 meters"
<< ".25 meters"
<< average(oneMeter) << low(oneMeter) << high(oneMeter)
<< average(hMeter) << low(hMeter) << high(hMeter)
<< average(qMeter) << low(qMeter) << high(qMeter);
}
if (solDay == 3) //processes data for the third solar day
{
input >> solDay >> localTime >> decSol
>> newOneMeter >> newHMeter >> newQMeter;
oneMeter = oneMeter + newOneMeter;
hMeter = hMeter + newHMeter;
qMeter = qMeter + newQMeter;
count++;
output << solDay << fixed << setprecision(1) << setw(5)
<< "Solar" << "Average" << "Low" << "High"
<< average(oneMeter) << low(oneMeter) << high(oneMeter)
<< average(hMeter) << low(hMeter) << high(hMeter)
<< average(qMeter) << low(qMeter) << high(qMeter);
}
}
cout << endl << "The output.dat file has been written and transmitted.";
/*
reads first line. Assigns first string to 'int solDay'
second to 'string time', third to decSol, fourth to oneMeter,
fifth to hMeter and sixth to qmeter. Meters should have setw().
*/
getch();
return 0;
input.close();
output.close();
}
//functions used in main
double low(double lowTemp)
{
int test = 10,000;
double least;
if (lowTemp < test)
{
lowTemp = test;
lowTemp = least;
}
return least;
}
double high(double highTemp)
{
int test = 10,000;
double most;
if (highTemp < test)
{
highTemp = test;
highTemp = most;
}
return most;
}
float average(double avgTemp)
{
avgTemp = avgTemp / count;
return avgTemp;
}
I searched this error when I ran into it. The cause of my troubles? I was trying to give a class the same name as #define value that had been included into my project from a 3rd party API header. Trying a different class name, I got it to compile!