error:control reaches end of non-void function [-Werror=return-type]
在做LeetCode上的题目时,出现了这个错误,
原代码如下:
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
vector<int> v;
unordered_map<int, int> m;
for(int i=;i<nums.size();++i)
{
int tt=target-nums[i];
if(m.find(tt)!=m.end())
{
v.push_back(m[tt]);
v.push_back(i);
return v;
}
else
m[nums[i]]=i;
}
//return v;
}
};
可以看到18行被我注释掉了,就是这行缺失导致出现程序可能不会返回值。
error:control reaches end of non-void function [-Werror=return-type]的更多相关文章
- error: control may reach end of non-void function [-Werror,-Wreturn-type]
编译出现如下错误 error: control may reach end of non-void function [-Werror,-Wreturn-type] 这个错误可能和编译器有关(在相同代 ...
- Error:java: Can‘t generate mapping method with primitive return type.报错
原因:Spring项目中使用了JPA以及Mybatis–mapper文件注解引错包导致编译错误 解决: 错误:import org.mapstruct.Mapper;正确路径:import org.a ...
- [TypeScript] Infer the Return Type of a Generic Function Type Parameter
When working with conditionals types, within the “extends” expression, we can use the “infer” keywor ...
- warning: control reaches end of non-void function
用gcc编译一个程序的时候出现这样的警告: warning: control reaches end of non-void function 它的意思是:控制到达非void函数的结尾.就是说你的一些 ...
- Control reaches end of non-void function 犯过最傻的错误
之所以会报“Control reaches end of non-void function ”的警告,时因为方法名中缺少返回类型.正确的写法如下: +(void)setMobile:(NSStrin ...
- warning: control reaches end of non-void function 和 warning: implicit declaration of function 'rsgClearColor' is invalid in C99
用gcc编译一个程序的时候出现这样的警告: warning: control reaches end of non-void function 它的意思是:控制到达非void函数的结尾.就是说你的一些 ...
- 【gcc】warning: control reaches end of non-void function
用gcc编译一个C程序的时候出现这样的警告: warning: control reaches end of non-void function 它的意思是:控制到达非void函数的结尾.就是说你的一 ...
- bug_ warning: control reaches end of non-void function
摘要 在leetcode上编译时,它显示我编译错误 warning: control reaches end of non-void function 它的意思是:控制到达非void函数的结尾.就是说 ...
- implicitly declaring function 'malloc' with type void *(unsigned long ) 错误 解决
errror : implicitly declaring function 'malloc' with type void *(unsigned long ) Be sure to includ ...
随机推荐
- C# 64位win7下DllImport LoadLibrary函数失败 z
[DllImport["kernel32.dll"]] static extern IntPtr LoadLibrary(string lpFileName); public vo ...
- 2.安装 Android SDK
安装Android SDK Android SDK(Software Development Kit,软件开发工具包)提供了 Android API 库和开发工具构建,测试和调试应用程序.简单来讲,A ...
- 如何在ubuntu上安装virtualbox的driver module vboxdrv
干净的ubuntu安装完毕之后是没有vboxdrv这个driver module的. 新建一个folder jerry_virtualbox: 使用wget下载virtualbox安装包:https: ...
- 异常:Caused by: java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z
Spring3.0 + Hibernate3.5:启动服务器报:Caused by: java.lang.NoSuchMethodError: javax.persistence.OneToMany. ...
- 【[AHOI2012]树屋阶梯】
卡特兰数! 至于为什么是卡特兰数,就稍微说那么一两句吧 对于一个高度为\(i\)的阶梯,我们可以在左上角填一个高度为\(k\)的阶梯,右下角填一个高度为\(i-1-k\)的阶梯剩下的我们用一个大的长方 ...
- HashMap对HashCode碰撞的处理
先说Java之外的,什么是拉链法?怎么解决冲突的: 拉链法解决冲突的做法是:将所有关键字为同义词的结点链接在同一个单链表中. 若选定的散列表长度为m,则可将散列表定义为一个由m个头指针组成的指针数组t ...
- 正则匹配之replace方法
在我印象中,replace方法就是一个正则匹配,然后一股脑的替换掉匹配到的内容的一个方法. 在一次任务需求中,有这么一个需求,一行字符串里面,替换相应字符串,具体就是匹配到‘A’然后把‘A’替换成‘a ...
- 【luogu P2590 [ZJOI2008]树的统计】 题解
题目链接:https://www.luogu.org/problemnew/show/P2590 我想学树剖QAQ #include <cstdio> #include <cstri ...
- <body> 中的 JavaScript 函数
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...
- 论坛数据转换discuz论坛?
http://www.bbstobbs.com/thread-397-1-1.html