我一直在
二进制“>>”没有找到哪个操作符采用“类型”类型的右侧操作数(或者没有可接受的转换)或错误代码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;
}
答案 0 :(得分:3)
您缺少包含文件。
#include <string>