如果 else 语句中的 C++ 错误,我的语法有什么问题
c++ error in if else statement, what is wrong with my syntax?
我在我的 if else 语句中收到以下错误。语法有什么问题?
ass4.cpp:46:错误:无法将"std::string"转换为"int"ass4.cpp:49:错误:预期"("在"else"之前
41 if ((type_f == 1) && (type_s == 1))
42 {
43 cout << "11" << endl;
44
45 // 1 1 = iterative, reverse
46 return reverse(str_input);
47 }
48
49 if else((type_f == 1) && (type_s == 2))
50 {
51 cout << "12" << endl;
52
53 return palin_l(str_input);
54 }
if else((type_f == 1) && (type_s == 2))
^^^^^^^
语法无效,请更新为
else if ((type_f == 1) && (type_s == 2))
它还抱怨将string
与int
类型进行比较,type_s
字符串类型吗?
-
您的函数是否定义为返回
int
?reverse
返回std::string
吗? 这是行不通的。 更改一个或另一个。 -
if else
不是法律语法。 从您那里的情况来看,您似乎应该切换到else if
.
相关文章:
- 我的神经网络不起作用 [XOR 问题]
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 我的字符计数代码计算错误.为什么
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 为什么当我正确执行语法时,我的代码输出为 0
- 我的代码似乎在查找最大数字时存在语法错误
- 为什么我的地图迭代器中存在语法错误
- vim 你完成了我在 C++11 语法上的错误
- P/调用语法 - 我是否在 C# 中正确翻译了我的C++函数
- 如果我的语法中有"或"("|"),如何将数据解析为具有提升精神C++结构
- 我的语法在这里正确吗?C++
- 如果 else 语句中的 C++ 错误,我的语法有什么问题
- 为什么我的代码生成语法错误
- 有人可以看看我的代码吗?错误 C2059:语法错误:"公共"
- 当我的着色器文件的所有信息都被正确读取到字符串中并且语法正确时,OpenGL为什么会出现语法错误
- 我的代码语法不正确的地方
- 我的代码中有一个错误,可能是语法或我找不到的 if 语句。编程新手
- 在我的解释器上为脚本代码实现语法检查器的最佳方式是什么
- 从朋友那里访问私有变量,我认为我的语法是错误的
- 如果我包含一些头文件,我的程序就会出现很多缺失、语法和未声明的错误.(c++)