c++第四天

#include 

using namespace std;
class Stu
{
    friend const bool operator==(const Stu &p1,const Stu &p2);
    friend const bool operator<(const Stu &p1,const Stu &p2);
    friend const bool operator>(const Stu &p1,const Stu &p2);
    friend const bool operator>=(const Stu &p1,const Stu &p2);
    friend const bool operator<=(const Stu &p1,const Stu &p2);
    friend const bool operator!=(const Stu &p1,const Stu &p2);
private:
    int a;
    int b;
public:
    Stu(){}
    Stu(int a,int b):a(a),b(b){}


};
const bool operator==(const Stu &p1,const Stu &p2)
{
    if(p1.a==p2.a&&p1.b==p2.b)
        return true;
    else
        return false;
}
const bool operator<(const Stu &p1,const Stu &p2)
{
    if(p1.a(const Stu &p1,const Stu &p2)
{
    if(p1.a>p2.a&&p1.b>p2.b)
        return true;
    else
        return false;
}
const bool operator>=(const Stu &p1,const Stu &p2)
{
    if(p1.a>=p2.a&&p1.b>=p2.b)
        return true;
    else
        return false;
}
const bool operator<=(const Stu &p1,const Stu &p2)
{
    if(p1.a<=p2.a&&p1.b<=p2.b)
        return true;
    else
        return false;
}
const bool operator!=(const Stu &p1,const Stu &p2)
{
    if(p1.a!=p2.a&&p1.b!=p2.b)
        return true;
    else
        return false;
}
int main()
{
    Stu s1(90,50);
    Stu s2(90,50);
    if(s1s2)
    {
        cout<<"s1>s2"<=s2)
    {
        cout<<"s1>=s2"<

c++第四天_第1张图片

 

你可能感兴趣的:(c++,开发语言)