datemid.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:

C#编程

开发平台:

Visual C++

  1. //=====================================
  2. // datemid.cpp
  3. //=====================================
  4. #include"date.h"
  5. #include"datemid.h"
  6. #include<iostream>
  7. //-------------------------------------
  8. DateMid::DateMid(const std::string s):m_p(new Date(s)){}
  9. //-------------------------------------
  10. DateMid::DateMid(int n):m_p(new Date(n)){}
  11. //-------------------------------------
  12. DateMid::DateMid(int y, int m, int d):m_p(new Date(y,m,d)){}
  13. //-------------------------------------
  14. DateMid::DateMid(const Date& d):m_p(new Date(d)){}
  15. //-------------------------------------
  16. DateMid::~DateMid(){ delete m_p; }
  17. //-------------------------------------
  18. DateMid DateMid::operator+(int n)const{ return *m_p + n; }
  19. //-------------------------------------
  20. DateMid& DateMid::operator+=(int n){ *m_p += n; return *this; }
  21. //-------------------------------------
  22. DateMid& DateMid::operator++(){ *m_p += 1; return *this; }
  23. //-------------------------------------
  24. int DateMid::operator-(DateMid& d)const{ return *m_p - *(d.m_p); }
  25. //-------------------------------------
  26. std::ostream& operator<<(std::ostream& o, const DateMid& d){
  27.   return o<<*(d.m_p);
  28. }//------------------------------------
  29.