第12周课后实践(4)

来源:互联网 发布:新纪元查账软件 编辑:程序博客网 时间:2024/04/29 16:04


/*
All rights reserced.
文件名称:main.cpp
作者:李鑫
 完成日期:2016.5.31

问题描述 :阅读程序,写出程序运行结果!

*/

#include<iostream>using namespace std;class Pair{    int m;    int n;public:    Pair(int i, int j):m(i),n(j) {}    bool operator >(Pair p) const;};bool Pair::operator>(Pair p)const{    if (m!=p.m)        return m>p.m;    return n>p.n;}int main(){    Pair p1(3,4),p2(4,3), p3(4,5);    cout<<(p1>p2);    cout<<(p2>p1)<<(p2>p3)<<(p3>p2);    return 0;}

运行结果:


0 0
原创粉丝点击