问题描述
我是一个完整的初学者,并且我一直在看这段代码两天了,但我一直想不通自己所做的工作,不断产生此错误消息:
main.cpp: In function ‘int main()’:
main.cpp:19:43: error: no match for ‘operator>>’ (operand types are ‘std::basic_ostream<char>’ and ‘const char [25]’)
value of num1 =" << num1 >> " and the value of num2 " << num2 >> ".";
~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/string:53:0,from /usr/include/c++/7/bits/locale_classes.h:40,from /usr/include/c++/7/bits/ios_base.h:41,from /usr/include/c++/7/ios:42,from /usr/include/c++/7/ostream:38,from /usr/include/c++/7/iostream:39,from main.cpp:1:
/usr/include/c++/7/bits/basic_string.tcc:1465:5: note: candidate: template<class _CharT,class _Traits,class _Alloc> std::basic_istream<_CharT,_Traits>& std::operator>>(std::basic_istream<_CharT,_Traits>&,std::__cxx11::basic_string<_CharT,_Traits,_Alloc>&)
operator>>(basic_istream<_CharT,_Traits>& __in,^~~~~~~~
/usr/include/c++/7/bits/basic_string.tcc:1465:5: note: template argument deduction/substitution failed:
main.cpp:19:46: note: ‘std::basic_ostream<char>’ is not derived from ‘std::basic_istream<_CharT,_Traits>’
lue of num1 =" << num1 >> " and the value of num2 " << num2 >> ".";
^~~~~~~~~~~~~~~~~~~~~~~~~~
#include <iostream>
#include <string>
using namespace std;
int main()
{
//variable declaration
int num1,num2,newNum,SECRET;
SECRET = 11;
double RATE = 12.50;
string name;
double hoursWorked,wages;
//executable statements
cout << "Give me two integers";
cin >> num1 >> num2;
cout << "The value of num1 =" << num1 >> " and the value of num2 " << num2 >> ".";
newNum = (num1*2)+num2;
cout<< "The new value of newNum =" << newNum;
newNum = newNum+ SECRET;
cout<< "The new value of newNum =" << newNum;
cout << "What's your last name?";
cin >> name;
cout << "Enter a decimal number between 0 and 70";
cin >> hoursWorked;
wages = RATE*hoursWorked;
cout << "Name: " << name << "\n" << "Pay Rate: $" << RATE << "\n" << "Hours Worked: "<<hoursWorked << "\n" << "Salary: $ " << wages;
return 0;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)