出错代码: for(int j=0;j<detector.size();j++)
出错原因分析: detector 是一个Vector容器 ,detecot.size() 在容器说明中 被定义为: unsigned int 类型, 而j是int 类型 所以会出现: 有符号/无符号不匹配警告
错误改正: 定义j为unsigned类型后就可以了
即: for(unsigned int j=0;j<detector.size();j++)
或者: for(size_t int j=0;j<detector.size();j++)
出错原因分析: detector 是一个Vector容器 ,detecot.size() 在容器说明中 被定义为: unsigned int 类型, 而j是int 类型 所以会出现: 有符号/无符号不匹配警告
错误改正: 定义j为unsigned类型后就可以了
即: for(unsigned int j=0;j<detector.size();j++)
或者: for(size_t int j=0;j<detector.size();j++)
本文探讨了在使用Vector容器时出现的有符号/无符号类型不匹配警告问题,并提供了两种解决方案:一是将循环变量定义为unsigned int类型;二是使用size_t类型。
1282

被折叠的 条评论
为什么被折叠?



