紧急求助关于操作符重载相关的一个程序错误问题
最近写了一个集合类,主要实现集合的交、并等运算,可现在程序总通过,请各位大侠帮助一下,下面是部分代码:
头文件:
class CJiHe
{
public:
CJiHe(void);
virtual ~CJiHe();
CJiHe(CStringArray &arrHS);//从字符串创建,自动去除非法字符与重复字符
CJiHe(const CJiHe &other);//拷贝构造
CJiHe operator + (const CJiHe &other) const;//加法重载,并集
CJiHe operator - (const CJiHe &other) const;//减法重载,差集
CJiHe operator * (const CJiHe &other) const;//乘法重载,交集
BOOL FindInString(CStringArray &arrHS, CString strHE);
private:
CStringArray m_arrHouseSet;
};
实现CPP:
//----------JiHe.cpp----------已略去不重要的内容----------
BOOL CJiHe::FindInString(CStringArray &arrHS, CString strHE)
{
//全局函数
//从字符串中查找字符
//有则返回1,无则返回0
int count = arrHS.GetSize();
CString str="";
for (int i = 0; i<count; i++)
{
str = arrHS.GetAt(i);
if (str == strHE)
return TRUE;
}
return FALSE;
}
CJiHe CJiHe::operator + (const CJiHe &other) const
{
//加法重载,并集
CStringArray arrtemp;
int count1 = other.m_arrHouseSet.GetSize();
int count2 = m_arrHouseSet.GetSize();
CString str="";
BOOL bFind = FALSE;
if(count1<=count2)
{
for(int i=0;i<count1;i++)
{
str = other.m_arrHouseSet.GetAt(i);
bFind = FindInString(m_arrHouseSet,str);
if(bFind)
{
arrtemp.Add(str);
}
}
}
else
{
for(int j=0;j<count2;j++)
{
str = m_arrHouseSet.GetAt(j);
bFind = FindInString(other.m_arrHouseSet,str);
if(bFind)
{
arrtemp.Add(str);
}
}
}
return CJiHe(arrtemp);
}
就是在上述函数(“+”运算)中,FindInString总报以下错:
error C2662: 'FindInString' : cannot convert 'this' pointer from 'const class CJiHe' to 'class CJiHe &'
Conversion loses qualifiers
不知何故,请各位大侠帮助!!!谢谢