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 ...
随机推荐
- 设计模式之模板方法模式(Template)
一.介绍 模板方法模式是编程中经常用到的模式.它定义了一个操作中的算法骨架,将某些步骤延迟到子类中实现.这样,新的子类可以在不改变一个算法结构的前提下重新定义该算法的某些特定步骤. 二.场景举例 当一 ...
- C# 轻松读取、改变文件的创建、修改、访问时间 z
// 读取文件的创建.修改.访问时间FileInfo fi = new FileInfo("C://test.txt");Console.WriteLine(fi.Creation ...
- 基于FPGA的HDMI显示设计(三)
上一篇:基于FPGA的VGA显示设计(二) 10月10日 ~ 20日期间实习,令我万万没想到的是实习题目是 “便携式高清电视显示屏测试系统原型设计” 也就是 “基于FPGA的视频显示”. 实习要求用 ...
- CRM和ERP的Sales Organization的映射关系
在如下的配置里可以维护CRM和ERP的Sales Organization的映射关系. 例如,ERP的编号为0001的销售组织映射到CRM的编号为O 50040102的销售组织: 这种映射关系存储在表 ...
- bash shell脚本之查看系统环境变量
查看当前系统环境变量 cat test2: #!/bin/bash # display user information from the system. echo "User info f ...
- bootstrapTable refresh 方法使用简单举例
本文就bootstrapTable refresh 方法如何传递参数做简单举例说明. 下面代码中,一个table,一个button,单击button会触发刷新表格操作. <!DOCTYPE ht ...
- HDU 5536 字典树
题意:就是公式. 这现场赛O(n^3)能过,觉得太没天理了. 做法:字典树,枚举两个数,然后在字典树上贪心的跑. #include <bits/stdc++.h> using namesp ...
- python nmap模块 端口探测
今天添加端口探测功能,主要实现方式是通过nmap模块调用,扫描1-65535端口.上一篇中已经将UP的PC机全部获取到,这里直接从已知在线的PC中进行端口扫描就可以了,会节省很多时间. 代码如下,还是 ...
- js数组、字符串常用方法
数组方面 push:向数组尾部增加内容,返回的是新数组的长度. var arr = [1,2,3]; console.log(arr); var b = arr.push(4); console.lo ...
- 【转】ConcurrentHashMap原理分析(1.7与1.8)
https://www.cnblogs.com/study-everyday/p/6430462.html 前言 以前写过介绍HashMap的文章,文中提到过HashMap在put的时候,插入的元素超 ...