gpt4 book ai didi

c++ - 数字常量之前的预期不合格 ID?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:10:46 33 4
gpt4 key购买 nike

我在 102、115 和 128 行 上遇到错误。我究竟做错了什么?它说:

Expected unqualified-id before numeric constant

我不知道那是什么意思。我已经尝试修复这个问题一个星期了,它将于下周三在我的 C++ 类(class)中到期。我真的可以在这里使用一些外部建议。我做错了什么:

#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;
}

最佳答案

我遇到这个错误时搜索了这个错误。我烦恼的原因?我试图给一个与#define 值同名的类,该值已从第 3 方 API header 包含到我的项目中。尝试不同的类名,我让它编译了!

关于c++ - 数字常量之前的预期不合格 ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15059810/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com