C++ &引用;预期的'';在返回语句之后,有人能告诉我我的代码有什么问题吗?
我尽了最大努力,但无法找出我的代码出了什么问题。 我收到一个错误代码C++ &引用;预期的'';在返回语句之后,有人能告诉我我的代码有什么问题吗?,c++,compiler-errors,C++,Compiler Errors,我尽了最大努力,但无法找出我的代码出了什么问题。 我收到一个错误代码“错误:返回语句后应为“;”。 注意:这是我除了“hello world”之外的第一个节目,任何帮助都将不胜感激 #include <iostream> using namespace std; int main() { int celsius, fahrenheit; //Get degrees in celsius cout << "Please input degrees Celsius: \
“错误:返回语句后应为“;”。
注意:这是我除了“hello world”之外的第一个节目,任何帮助都将不胜感激
#include <iostream>
using namespace std;
int main() {
int celsius, fahrenheit;
//Get degrees in celsius
cout << "Please input degrees Celsius: \n";
cin >> celsius;
//convert celsius to fahrenheit
fahrenheit = celsius * 1.8 + 32;
//display degrees farhenheit/ thank you message
cout << "\n" << "Degrees Fahrenheit: \n" << fahrenheit << "\n";
cout << "\n" << "Thank you for using my Celsius to Fahrenheit converter. \n" << "\n";
{
int yes = 1, no = 0;
cout << "do you wish to convert again? \n";
cin >> yes;
if (yes == 1) {
return cout << "please enter degrees Celsius" ;
cin >> celsius;
//convert celsius to fahrenheit
fahrenheit = celsius * 1.8 + 32;
cout << "\n" << "Degrees Fahrenheit: \n" << fahrenheit << "\n";
} else {
return cout "fine";
}
}
return 0;
}
#包括
使用名称空间std;
int main(){
整数摄氏度,华氏度;
//以摄氏度表示
温度>摄氏度;
//将摄氏度转换为华氏度
华氏温度=摄氏度*1.8+32;
//显示farhenheit度/感谢信息
cout在cout
之前删除两个垃圾return
并添加那么,您的代码中有3个错误:
1.在您编写的if块中return coutreturn cout是否有不必要的大括号{}
也是。cout
不返回任何东西,我想,这是非常正确的,因为cout
是一个东西,而不是一个操作符。操作符是我在回答中的意思是cout不返回温度值。它只是在他的屏幕上显示值。我只是不想告诉他关于ostr的事情而把他弄糊涂eam反对和运算符重载。所以我只是告诉他从这些语句中删除“return”并使用“不混淆的愿望是高尚的,但助长了一种流行的误解,即开始时是不好的,伙计,我只是添加了一个说明”
#include <iostream>
using namespace std;
int main()
{
int celsius, fahrenheit;
//Get degrees in celsius
cout << "Please input degrees Celsius: \n";
cin >> celsius;
//convert celsius to fahrenheit
fahrenheit = celsius * 1.8 + 32;
//display degrees farhenheit/ thank you message
cout << "\n" << "Degrees Fahrenheit: \n" << fahrenheit << "\n";
cout << "\n" << "Thank you for using my Celsius to Fahrenheit converter. \n" << "\n";
int yes = 1;
cout << "do you wish to convert again? \n";
cin >> yes;
if (yes == 1)
{
cout << "please enter degrees Celsius" ;
cin >> celsius;
//convert celsius to fahrenheit
fahrenheit = celsius * 1.8 + 32;
cout << "\n" << "Degrees Fahrenheit: \n" << fahrenheit << "\n";
}
else
{
cout << "fine";
}
return 0;
}
return cout << "please enter degrees Celsius" ; //line 31
return cout "fine"; //line 41