本文介绍了逗号左边的操作数没有效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我在这个警告消息中遇到了一些麻烦,它在一个模板容器类中实现 要合并条件,请使用&& 或 || 。 k k< sizeC || l< (sizeC-index)//任何一个都可以。 I'm having some trouble with this warning message, it is implemented within a template container classint k = 0, l = 0; for ( k =(index+1), l=0; k < sizeC, l < (sizeC-index); k++,l++){ elements[k] = arryCpy[l]; } delete[] arryCpy;this is the warning i getcont.h: In member function `void Container<T>::insert(T, int)':cont.h:99: warning: left-hand operand of comma has no effectcont.h: In member function `void Container<T>::insert(T, int) [with T = double]':a5testing.cpp:21: instantiated from herecont.h:99: warning: left-hand operand of comma has no effectcont.h: In member function `void Container<T>::insert(T, int) [with T = std::string]':a5testing.cpp:28: instantiated from herecont.h:99: warning: left-hand operand of comma has no effect>Exit code: 0 解决方案 The comma expression a,b,c,d,e is similar to{ a; b; c; d; return e;}therefore, k<sizeC, l<(sizeC - index) will only return l < (sizeC - index). To combine conditionals, use && or ||.k < sizeC && l < (sizeC-index) // both must satisfyk < sizeC || l < (sizeC-index) // either one is fine. 这篇关于逗号左边的操作数没有效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-24 20:00