错误C2679:二进制'<<':找不到运算符,它接受类型为"std :: string"的右侧操作数

lia*_*ang -1 c++ string io operators

码:

    #include "stdafx.h"
    #include <iostream>
    #include <fstream>
    #include <string.h>

    using namespace std;
    int main()
        {
            ifstream fin ("ride.in.txt");
            ofstream fout ("ride.out.txt");
            int ta, tb;unsigned int i;
            ta = tb = 1;
            string a, b;
            fin >> a >> b;
            for (i = 0; i < a.size(); i++)
                ta = ta * (a[i] - 'A' + 1) % 47;
            for (i = 0; i < b.size(); i++)
                tb = tb * (b[i] - 'A' + 1) % 47;
            if (ta == tb)
                fout << "GO" << endl;
            else    
                fout << "STAY" << endl;
            return 0;
        }
Run Code Online (Sandbox Code Playgroud)

错误:

error C2679: 
binary '<<' : no operator found which takes a right-hand operand of type  “std::string”
Run Code Online (Sandbox Code Playgroud)

hmj*_*mjd 17

我认为问题是:

#include <string.h>
Run Code Online (Sandbox Code Playgroud)

改成:

#include <string>
Run Code Online (Sandbox Code Playgroud)


Bo *_*son 5

std::string运营商在所定义的<string>报头中.

标题<string.h>用于C风格的字符串函数.