在做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]的更多相关文章

  1. error: control may reach end of non-void function [-Werror,-Wreturn-type]

    编译出现如下错误 error: control may reach end of non-void function [-Werror,-Wreturn-type] 这个错误可能和编译器有关(在相同代 ...

  2. Error:java: Can‘t generate mapping method with primitive return type.报错

    原因:Spring项目中使用了JPA以及Mybatis–mapper文件注解引错包导致编译错误 解决: 错误:import org.mapstruct.Mapper;正确路径:import org.a ...

  3. [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 ...

  4. warning: control reaches end of non-void function

    用gcc编译一个程序的时候出现这样的警告: warning: control reaches end of non-void function 它的意思是:控制到达非void函数的结尾.就是说你的一些 ...

  5. Control reaches end of non-void function 犯过最傻的错误

    之所以会报“Control reaches end of non-void function ”的警告,时因为方法名中缺少返回类型.正确的写法如下: +(void)setMobile:(NSStrin ...

  6. 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函数的结尾.就是说你的一些 ...

  7. 【gcc】warning: control reaches end of non-void function

    用gcc编译一个C程序的时候出现这样的警告: warning: control reaches end of non-void function 它的意思是:控制到达非void函数的结尾.就是说你的一 ...

  8. bug_ warning: control reaches end of non-void function

    摘要 在leetcode上编译时,它显示我编译错误 warning: control reaches end of non-void function 它的意思是:控制到达非void函数的结尾.就是说 ...

  9. implicitly declaring function 'malloc' with type void *(unsigned long ) 错误 解决

    errror :   implicitly declaring function 'malloc' with type void *(unsigned long ) Be sure to includ ...

随机推荐

  1. spring与mybatis的整合

    整合的思路 SqlSessionFactory对象放到spring容器中作为单例存在. 传统dao的开发方式中,从spring容器中获得sqlsession对象. Mapper代理形式中,从sprin ...

  2. ios端微信浏览器禁止上下滑动

    在body里的第一个div容器中添加 position:fixed

  3. 将springboot打包成的jar文件做成windows服务

    1.在idea中用maven将程序打成jar,放到运行的目录中. 2.去github上面下载winsw: https://github.com/kohsuke/winsw/releases 3. 将W ...

  4. Visual Stuio 2010 常用快捷及操作

    1.如果你想复制一行代码(超级长,鼠标拖老久的),只需要在这行的空白处 CTRL+C 同理,剪贴一行 CTRL+X 删除一行 CTRL+L 2.显示方法里的参数,以前每次都是手动删括号. CTRL+S ...

  5. IOS 触摸事件的处理

    触摸事件的处理1.判断触摸点在谁身上: 调用所有UI控件的- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event 2.pointIn ...

  6. MySQL30条规范解读

    转载自:https://mp.weixin.qq.com/s?__biz=MjM5ODYxMDA5OQ==&mid=2651959906&idx=1&sn=2cbdc66cfb ...

  7. lua 语句学习

    就如同C里的if else,while,do,repeat.就看lua里怎么用: 1.首先看if else t = {1,2,3} local i = 1 if t[i] and t[i] % 2 = ...

  8. 2016 ACM/ICPC亚洲区大连站 F - Detachment 【维护前缀积、前缀和、二分搜索优化】

    F - Detachment In a highly developed alien society, the habitats are almost infinite dimensional spa ...

  9. 解决 Database Configuration Assistannt安装oracle实例使的 警告

    在创建到85%的时候报错,错误如下: 解决办法: 经过查看警告中给出的日志文件F:\develop\oracle_data\app\Administrator\cfgtoollogs\dbca\tes ...

  10. 【luogu P3390 矩阵快速幂】 模板

    题目链接:https://www.luogu.org/problemnew/show/P3390 首先要明白矩阵乘法是什么 对于矩阵A m*p  与  B p*n 的矩阵 得到C m*n 的矩阵 矩阵 ...