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 ...
随机推荐
- DB2数据库创建数据库操作过程
/* author simon */ 例:数据库:NCDB2用户 :DB2ADMIN/DB2ADMIN备份库路径:D:/bank 一.恢复数据库1.启动数据库运行->db2cmd->db2 ...
- 【Leetcode】【Easy】Plus One
Given a non-negative number represented as an array of digits, plus one to the number. The digits ar ...
- GO Lang学习笔记 - 基础知识
Go lang Learn Note 标签(空格分隔): Go Go安装和Go目录 设置环境变量GOROOT和GOPATH,前者是go的安装目录,后者是开发工作目录.go get包只会将包下载到第一个 ...
- url规范化:解决从baidu.com到www.baidu.com的
通过 301重定向可以实现 把www.baidu.com和baidu.com合并,并把之前的域名也一并合并. 有两种实现方法: 第一种方法是判断nginx核心变量host(别名功能): server ...
- 使用VM Tools让VMware虚拟机里的ubuntu能够共享Windows系统的文件夹
我们经常有这样的使用场景,在宿主机Windows(Linux)操作系统上通过VMware软件安装了一个Linux(Windows)的虚拟机, 然后需要在两种操作系统中通过某种介质共享数据. 一种比较麻 ...
- LeetCodeOJ刷题之14【Longest Common Prefix】
Longest Common Prefix Write a function to find the longest common prefix string amongst an array of ...
- 【转】JS模块化工具requirejs教程(一):初识requirejs
随着网站功能逐渐丰富,网页中的js也变得越来越复杂和臃肿,原有通过script标签来导入一个个的js文件这种方式已经不能满足现在互联网开发模式,我们需要团队协作.模块复用.单元测试等等一系列复杂的需求 ...
- 小练习——关于循环条件---for
1.打印100个“非常”的句子 static void Main(string[] args) { //打印20个“非常" Console.WriteLine("打印100个非常& ...
- 行云管家 V4.7产品新特性-国际化版本、支持Oracle的数据库审计、主机密码自动修改策略 发布日期:2018-11-22
行云管家在线体验: 行云管家[官网]-领先的云计算管理平台-云安全,堡垒机,自动化运维 行云管家新手有礼活动: 行云管家新手有礼,新用户1元即可体验专业版-优惠券 发布日期:2018-11-22 ...
- 学大伟业 Day 1 培训总结
第一天培训,讲的基本算法,东西很多.还有些数论,图论,数据结构and some small tricks 一.输入输出技巧 //输入输出技巧 /* scanf.printf:速度快,需要记忆不同数据类 ...