出錯代碼: 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++)
或者單獨定義一個變量
例如int m=detecto.size();
這樣在比較的時候不會出錯