重载操作符
2016-10-09 09:42 雄风狂飙 阅读(85) 评论(0) 收藏 举报#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class woCreditRule{
public:
int m_lowLevel ;//条件低水平
int m_highLevel ;//条件高水平
double m_WoCreditType;//Wo信用分取值
double m_ARPUType; //ARPU值取值
//eg [400,600,0.5,1] 表示沃信用分在400到600之间的
//用户最高可申请额度为max(0.5*ARPU,1*沃信用分)
woCreditRule(int l,int h,int w,int a)
{
m_lowLevel = l;
m_highLevel = h;
m_WoCreditType = w;
m_ARPUType = a;
}
~woCreditRule(){}
bool operator<(const woCreditRule& right ) const
{
return m_lowLevel < right.m_lowLevel;
}
friend ostream&
operator<<( ostream& os , const woCreditRule & right )
{
os<<"m_lowLevel=="<<right.m_lowLevel
<<"m_highLevel=="<<right.m_highLevel
<<"m_WoCreditType=="<<right.m_WoCreditType
<<"m_ARPUType=="<<right.m_ARPUType;
//os<<"m_lowLevel=="<<right.m_lowLevel;
return os;
}
};
void main()
{
vector<woCreditRule> rule;
woCreditRule wo = woCreditRule(1200,600,0.5,2.0);
rule.push_back(wo);
wo = woCreditRule(600,800,1.0,2.0);
rule.push_back(wo);
wo = woCreditRule(800,1000,1.0,2.5);
rule.push_back(wo);
sort(rule.begin(),rule.end());
for ( vector<woCreditRule>::iterator iter = rule.begin() ; iter != rule.end(); iter++ )
{
cout<<(*iter)<<endl;
}
}
浙公网安备 33010602011771号