cocos2dx——warning C4018: “<”: 有符号/无符号不匹配

warning C4018: “<”: 有符号/无符号不匹配
出错代码:  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++) 

版权声明:本文为hongkebobby原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。