#include<iostream>
using namespace std;
class CExample
{
public:
CExample(int i)
{
m_a = i;
}
bool operator>(const CExample& e)
{
if(this->m_a > e.m_a)
{
return true;
}
else
{
return false;
}
}
bool operator>=(const CExample& e)
{
if(this->m_a >= e.m_a)
{
return true;
}
else
{
return false;
}
}
bool operator<=(const CExample& e)
{
if(this->m_a <= e.m_a)
{
return true;
}
else
{
return false;
}
}
bool operator==(const CExample& e)
{
if(this->m_a == e.m_a)
{
return true;
}
else
{
return false;
}
}
private:
int m_a;
};
int main()
{
CExample c1(5);
CExample c2(6);
cout<<(c2==c2)<<endl;
return 0;
}
C++比较符重载
最新推荐文章于 2022-10-06 00:01:36 发布