打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
relation_compare_operator.cpp
/*
 * relation_operator.cpp
 *
 *  Created on: 2013-9-28
 *      Author: Administrator
 */

#if 0
#include<iostream.h>
class Rect
{
private:
    int length,width;
public:
    Rect(int l,int h)
{
        length = l; width = h;
}
    friend int operator > (Rect a,Rect b)
    {
        return (a.length*a.width) > (b.length*b.width)?1:0;
    }
    void display()
    {
        cout << "面积="<<length*width<<endl;
    }
};
int main(void)
{
    Rect rect1(5,5),rect2(4,7);
    cout << "rect1";
    rect1.display();
    cout << "rect2";
    rect2.display();
    if(rect1 > rect2)
        cout << "rect1的面积大于rect2的面积"<< endl;
    else
        cout << "rect1的面积小于rect2的面积"<< endl;
    return 0;
}

#endif



本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
C++ 创建一个类
C++ vector用法
使用lambda,远离bind
一个比较全的string类的实现(比较乱)
用OpenSSL 做HMAC(C++)
c++ 中函数操作符operator() 的使用
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服