类的加法
来源:互联网 发布:燕十八php百度网盘 编辑:程序博客网 时间:2024/06/11 05:00
#include<iostream>using namespace std;class data{private: int m, d, y; static int day[];public: data(int M, int D, int Y) { m = M; d = D; y = Y; } void display() { cout << "年" << y << "月" << m << "日" << d << endl; } data operator+(int n)const { data Data = *this; n += Data.d; while (n > day[Data.m - 1]) { n -= day[Data.m - 1]; if (++Data.m == 13) { Data.m = 1; Data.y++; } } Data.d = n; return Data; }};int data::day[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };int main(){ data d1(03, 05, 2012); d1.display(); data d2 = d1 + 10; cout << "加上后" << endl; d2.display(); system("pause"); return 0;}
0 0
- 类的加法
- 一个加法的类模板源代码
- 只定义了加法的大数类
- 多项式的加法
- 不寻常的加法
- 日期的加法
- 简单的加法
- 虚数的加法运算
- 大数的加法
- 超长正整数的加法
- 整数的加法运算
- jQuery的加法运算
- shell的加法累加
- 大数的加法
- java--加法的实现
- 超长正整数的加法
- 两个多项式的加法
- 大数的加法
- Web Services
- linux下C++ gdb调试笔记
- win7与VMware ubuntu虚拟机实现文件共享
- uva 1201 - Taxi Cab Scheme(二分图匹配)
- ThinkPHP中Session用法详解
- 类的加法
- 云计算大赛准备之为ubuntu安装hadoop过程
- C语言中,为什么字符串可以赋值给字符指针变量
- 做好的自己
- AnguarJS $apply和$digesty
- ORA-00923: 未找到要求的 FROM 关键字
- 指向指针的指针
- Android Custom view —- bottom sheet
- angularjs[1.4.3]