hywelcode 2022-07-19 15:00 采纳率: 50%
浏览 410

[Error] no match for 'operator>>' ,如何解决?

错误
#include<iostream>
#include<fstream>
using namespace std;
int main() {
    cout << "ctiny(continuity)4" << endl;
    ofstream sin("c:\\ctiny.txt");
    string f;
    f = "qgq/awww/were/terrible/that/yyyyy/uuuu/III in/Oooo/popped/AAA and/sass/adds/FFF/gagged/high/Jjjkkkk/KKK/Lilly/zzz/xxx/cCCC/Viva/Bobby/Nunn/Mmmmp";
    sin>>f;
    cout<<"The solution file has been saved to the C drive"<<endl;
    string cti;
    while (true){
        cout << "input:"; 
        cin>>cti;
        if (cti == "qgq") {
            cout << "q";
        }
        else if (cti == "awww") {
            cout << "w";
        }
        else if (cti == "were") {
            cout << "e";
        }
        else if (cti == "terrible") {
            cout << "r";
        }
        else if (cti == "that") {
            cout << "t";
        }
        else if (cti == "yyyyy") {
            cout << "y";
        }
        else if (cti == "uuuu") {
            cout << "u";
        }
        else if (cti == "III") {
            cout << "i";
        }
        else if (cti == "Oooo") {
            cout << "o";
        }
        else if (cti == "popped") {
            cout << "p";
        }
        else if (cti == "AAA") {
            cout << "a";
        }
        else if (cti == "sass") {
            cout << "s";
        }
        else if (cti == "adds") {
            cout << "d";
        }
        else if (cti == "FFF") {
            cout << "f";
        }
        else if (cti == "gagged") {
            cout << "g";
        }
        else if (cti == "high") {
            cout << "h";
        }
        else if (cti == "Jjjkkkk") {
            cout << "j";
        }
        else if (cti == "KKK") {
            cout << "k";
        }
        else if (cti == "Lilly") {
            cout << "y";
        }
        else if (cti == "zzz") {
            cout << "z";
        }
        else if (cti == "xxx") {
            cout << "x";
        }
        else if (cti == "cCCC") {
            cout << "c";
        }
        else if (cti == "Viva") {
            cout << "v";
        }
        else if (cti == "Bobby") {
            cout << "b";
        }
        else if (cti == "Nunn") {
            cout << "n";
        }
        else if (cti == "Mmmmp") {
            cout << "m";
        }
        else {
            cout << "not";
        }
        cout<<"\ncontinue/break:";
        string cb;
        cin>>cb;
        if (cb=="continue"){
            continue;
        }
        if(cb=="break"){
            break;
        }
        
    }
}

运行结果:9 5 D:\c++cpp\Ctiny.cpp [Error] no match for 'operator>>' (operand types are 'std::ofstream {aka std::basic_ofstream}' and 'std::string {aka std::basic_string}')
  • 写回答

3条回答 默认 最新

  • 浪客 2022-07-19 15:21
    关注

    sin>>f; 有问题
    ofstream 没有>>
    应该是sin<<f;

    评论

报告相同问题?

问题事件

  • 创建了问题 7月19日

悬赏问题

  • ¥15 部分客户订单定位有误的问题
  • ¥15 如何在maya程序中利用python编写领子和褶裥的模型的方法
  • ¥15 Linux权限管理相关操作(求解答)
  • ¥15 Bug traq 数据包 大概什么价
  • ¥15 在anaconda上pytorch和paddle paddle下载报错
  • ¥25 自动填写QQ腾讯文档收集表
  • ¥15 DbVisualizer Pro 12.0.7 sql commander光标错位 显示位置与实际不符
  • ¥15 android 打包报错
  • ¥15 关于stm32的问题
  • ¥15 ncode振动疲劳分析中,noisefloor如何影响PSD函数?