无意中发现忘记了发布第二份代码,现将其展示
代码如下所示:
#include"ArrayListOp.h"
const ArrayList operator + (const ArrayList&lhs,const ArrayList&rhs) {
ArrayList c;
c += lhs;
c += rhs;
return c;
}
//关系运算符重载,按照字典序比较顺序表
bool operator == (const ArrayList&lhs,const ArrayList&rhs) {
if (lhs.getSize() != rhs.getSize()) return false;
for (int i = 0; i < lhs.getSize();i++) {
if (lhs[i] != rhs[i]) return false;
}
return true;
}
bool operator != (const ArrayList&lhs,const ArrayList&rhs) {
return !(lhs == rhs);
}
bool operator < (const ArrayList&lhs,const ArrayList&rhs) {
for (int i = 0; ; i++) {
if (i == rhs.getSize()) return false;
if (i == lhs.getSize()) return true;
if (lhs[i] != rhs[i]) return lhs[i] < rhs[i];
}
}
bool operator <= (const