我有以下代码:
#include <QCoreApplication>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int salary;
int childeren;
cout << "please type base salary=";
cin>> salary >> endl;
cout<< "plz type count your childeren=";
cin >> childeren >> endl ;
int Totalsalary=salary + childeren*10;
cout<< Totalsalary<< endl;
return 0;
}
我试图理解创建错误:
no match for 'operator>>' (operand types are 'std::basic_istream::__istream_type {aka std::basic_istream}' and '') cin>> salary >> endl; ^
最佳答案
std::endl
用于创建行尾和刷新流缓冲区。它应该与 std::cout
一起使用,而不是与 std::cin
一起使用。
所以更正你的下一行
cin>> salary >> endl;
到
cin>> salary;
关于c++ - 错误: 'operator>>' 不匹配(操作数类型为 'std::basic_istream<char> cin>> salary >> endl;^,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30554798/