【发布时间】:2011-12-30 12:32:39
【问题描述】:
代码:
#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;
}
错误:
error C2679:
binary '<<' : no operator found which takes a right-hand operand of type “std::string”
【问题讨论】:
-
没有问题,代码在clang上编译(去除未提供的预编译头时)。
-
它将在库发生在
<fstream>或<iostream>中包含<string>的任何编译器上编译。一个 C++ 标准头文件允许包含任何其他标准头文件。 -
我不明白为什么它被关闭了。它是一个真实的问题,并且有答案。无论如何,有一个类似问题的答案here。