我只是在学习C++的基础知识,而且我遇到了cout的一些问题。我写了几个简单的测试来打印hello world,一个简单的加法器函数,以及一个用于翻转字符串顺序的函数。一切运行良好,除了我的字符串函数,给我这个错误。会喜欢解释,谢谢。C++ cout操作数错误,输入错误ostream,字符串
错误:没有运营商 “< <” 这些操作数相匹配,操作数类型是STD:ostream的< < STD:字符串
#include <iostream>
using namespace std;
int adder(int a, int b)
{
return a + b;
}
int addOneToInput(int a)
{
return a + 1;
}
string flipStringOrder(string s)
{
string temp = "";
for (int i = 0; i < s.length; i ++)
{
char charTemp = (s.at(s.length() - i -1));
temp += charTemp;
}
return temp;
}
void main(){
cout << "Hello World" << endl;
int x = 5;
int y = 3;
cout << adder(x, y) << endl;
cout << flipStringOrder("moon") << endl;
cin.get();
}
你似乎并没有把执行#included ... –
'无效main'是不是一个合法的签名。 – chris