"错误:没有cin的操作员>>"我无法弄清楚我在这里做错了什么

OVE*_*ONE 2 c++ compiler-errors input

我是一名学生,上周刚开始学习C++,所以这个问题可能很低,但我无法弄明白.

我搜索了一下但找不到任何结果,或者我正在寻找错误的东西.

有两个cin部分.一个接受循环外的int,另一个接受循环内的字符串.

我收到一个编译错误,说""错误没有操作符匹配这些命令"即使我刚刚使用它们5行之前.

救命?

#include <fstream>
#include <iostream>

using namespace std;

int main()
{
    // variable declaration
    const double payIncrease = 7.6;
    string employeeName;
    double initialSalary;
    double backPay;
    double employeeAnnualSalary;
    double employeeMonthlySalary;

    int numEmployees;

    // streams of information
    ofstream outStream;
    outStream.open("employeeRecords.txt");

    // console io's
    cout<<"Enter how many employees you have:";
    cin>>numEmployees;

    for(int i = 0; i <numEmployees;i++)
    {
            cout<<"What is Employee number: "<<i<<"'s name:";
            cin>>employeeName;

            cout<<"How much does that employee earn now: ";
            cin>>initialSalary;
    }

    outStream <<"annual salary was: " << numEmployees;
    outStream.close();

    return 0;
Run Code Online (Sandbox Code Playgroud)

}

fre*_*low 5

这是一个实际编译的版本.你可以自己弄清楚你错过了什么;-)

#include <iostream>
#include <string>
using namespace std;

int main()
{
    cout << "Enter how many employees you have:";
    int numEmployees = 0;
    cin >> numEmployees;

    for(int i = 0; i < numEmployees; ++i)
    {
        cout << "What is Employee number: " << i << "'s name:";
        string employeeName;
        cin >> employeeName;
    }
}
Run Code Online (Sandbox Code Playgroud)