C++ operator overide example
来源:互联网 发布:锋芒网络剧第一季 编辑:程序博客网 时间:2024/06/08 07:16
a modified book example
#include "mytime.h"
#include <iostream>
using namespace std;
mytime::mytime()
{
// TODO Auto-generated constructor stub
}
mytime::~mytime()
{
// TODO Auto-generated destructor stub
}
mytime::mytime(int h,int m)
{
hours = h;
minutes = m;
}
mytime mytime::operator+(const mytime &t)const
{
mytime sum;
sum.minutes = minutes + t.minutes;
sum.hours = hours + t.hours + sum.minutes /60;
sum.minutes %=60;
return sum; //
}
void mytime::show()
{
cout<<"result hours"<<hours<<endl;
cout<<"result minutes"<<minutes<<endl;
}
int main()
{
mytime beforetime(2,40);
mytime addtime(3,55);
mytime resultime = beforetime + addtime;
resultime.show();
}
#include "mytime.h"
#include <iostream>
using namespace std;
mytime::mytime()
{
// TODO Auto-generated constructor stub
}
mytime::~mytime()
{
// TODO Auto-generated destructor stub
}
mytime::mytime(int h,int m)
{
hours = h;
minutes = m;
}
mytime mytime::operator+(const mytime &t)const
{
mytime sum;
sum.minutes = minutes + t.minutes;
sum.hours = hours + t.hours + sum.minutes /60;
sum.minutes %=60;
return sum; //
}
void mytime::show()
{
cout<<"result hours"<<hours<<endl;
cout<<"result minutes"<<minutes<<endl;
}
int main()
{
mytime beforetime(2,40);
mytime addtime(3,55);
mytime resultime = beforetime + addtime;
resultime.show();
}
- C++ operator overide example
- example of python operator overloadind
- operator.c
- C++Operator
- C + + operator precedence list
- [C++]C++ Operator Precedence
- c语言 cast operator
- C++operator用法.
- C++operator<<函数
- C++operator重载问题
- [C++]operator--重载
- [C++]operator overlord
- c++---operator重载++,--
- C语言中的Operator
- 学习C++(operator new 和 operator delete)
- 10 points about instanceof operator in Java with example
- C# virtual and overide
- [C++] CBT Hook Example
- 前端性能优化最佳实践
- 什么时候赚能大钱?(第五次——在哪里?)
- OpenOffice在Windows和Linux下启动
- COCOS2D屏幕适配
- shell学习之-sed用法解析
- C++ operator overide example
- PHP/Shell大文件数据统计并且排序
- 监听ContentProvider数据的改变
- toastmaster-250th meeting-20130706
- Struts框架下Nginx与Tomcat容器的深度整合实践
- HDU 1076 An Easy Task
- Spring技巧之活用FactoryBean
- MySQL数据库基准压力测试工具之MySQLSlap使用实例
- 抽象类的特点