我的介绍课快结束了,我一生都无法弄清楚这里发生了什么。首先,代码:
#include <iostream>
#include <fstream>
using namespace std;
int main( )
{
double id = 0.0;
double rate = 0.0;
double hours = 0.0;
double gross = 0.0;
ifstream wData;
wData.open("workers.txt", ios::in);
if (wData.is_open())
{
for (int count = 0; count < 8; count = count + 1)
{
wData << id << rate << hours;
gross = rate * hours;
cout << "Employee ID: " << id << "Gross Pay: " << gross << endl;
}
wData.close();
}
else
{
cout << "The file could not be opened." << endl;
}
system("pause");
return 0;
}
接下来,错误:
41 no match for 'operator<<' in 'wData << id'
那将在位wData << id << rate << hours;
我已经做了一些探索(我真的很喜欢尝试自己解决这些问题),但我无法准确指出发生了什么。我觉得这可能是一件很明显的事情,我在胡思乱想。