错误的任何修复:二进制">>"找不到运算符

Any fix for Error: binary ">>" no operator found

本文关键字:gt 找不到 运算符 二进制 任何修 错误      更新时间:2023-10-16

我不断获得

二进制">>"没有找到类型"类型"(或没有可接受的转换)或错误代码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 << "nnTip amount:t$" << tip;
    cout << "nTotal bill:t$" << tip + bill;
    cout << "nn" << fname << ":t$" << (tip + bill) / 3;
    cout << "n" << sname << ":t$" << (tip + bill) / 3;
    cout << "n" << tname << ":t$" << (tip + bill) / 3;
    return 0;
}

您缺少一个包含文件。

#include <string>