错误的任何修复:二进制“>>”找不到操作员

时间:2017-09-20 03:23:10

标签: c++

我一直在

  

二进制“>>”没有找到哪个操作符采用“类型”类型的右侧操作数(或者没有可接受的转换)或错误代码C2679。

我尝试添加#include <string>,这对我来说也不起作用。

以下是我感谢任何帮助的代码

#include<iostream>
#include <iomanip>

using namespace std;

int main()
{
    cout << setprecision(2) << fixed;
    string fname, sname, tname;
    float bill, tip;
    cout << "Enter first friend name: ";
    cin >> fname;
    cout << "\nEnter second friend name: ";
    cin >> sname;
    cout << "\nEnter third friend name: ";
    cin >> tname;
    cout << "\nEnter amount of bill: $";
    cin >> bill;
    tip = 0.15*bill;
    cout << "\n\nTip amount:\t$" << tip;
    cout << "\nTotal bill:\t$" << tip + bill;
    cout << "\n\n" << fname << ":\t$" << (tip + bill) / 3;
    cout << "\n" << sname << ":\t$" << (tip + bill) / 3;
    cout << "\n" << tname << ":\t$" << (tip + bill) / 3;
    return 0;
}

1 个答案:

答案 0 :(得分:3)

您缺少包含文件。

#include <string>