[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}')

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

问题出在你的第9行,sin >> f 应为 sin << f
望采纳。

这篇文章:C++:编译错误:no match for ‘operator==‘ 也许有你想要的答案,你可以看看
同时,你还可以查看手册:c++ 自动生成基于用户定义的 operator== 和 operator< 的比较运算符-operator!=, operator>, operator<=, operator>= 中的内容