Boost 计算信用卡 免息期

#include<boost/timer.hpp>
#include<boost/progress.hpp>
#include<boost/date_time/gregorian/gregorian.hpp>
using namespace boost;
using namespace boost::gregorian;
#include<iostream>
#include<vector>
using namespace std;
class credit_card {
public:
 string bank_name;
 int bill_day_no;
 credit_card(const char* bname,int no):bank_name(bname),bill_day_no(no) {}
 int calc_free_days(date consume_day=day_clock::local_day()) const {
  date bill_day(consume_day.year(),consume_day.month(),bill_day_no);
  if (consume_day > bill_day)
  {
   bill_day += months(1);
  }
  return (bill_day - consume_day).days() + 20;
 }
 friend bool operator<(const credit_card& l, const credit_card& r) {
  return l.calc_free_days() < r.calc_free_days();
 }
};
int main() {
 credit_card a("A bank", 25);
 credit_card b("B bank", 12);
 credit_card temp = std::max(a,b);
 cout << "You should use " << temp.bank_name << " ,free days = " << temp.calc_free_days() << endl;
}

你可能感兴趣的:(Boost 计算信用卡 免息期)