当前位置: 首页 > news >正文

东莞网站设计与网站制作/官网首页入口百度

东莞网站设计与网站制作,官网首页入口百度,水果电商运营方案,优质服务的网站建设Link c课作业&#xff0c;写了几万行代码还是第一次写 class &#xff0c;重载 /-//-- 和 cin/cout 什么的还是第一次。 话说提交作业这个平台居然还支持万能头文件&#xff0c;还是要点个赞的。 主要就是注意 friend 和 const 吧&#xff0c; /- 不能像 <,-,.. 一样加 con…


Link
c++课作业,写了几万行代码还是第一次写 class ,重载 +=/-=/++/--cin/cout 什么的还是第一次。
话说提交作业这个平台居然还支持万能头文件,还是要点个赞的。
主要就是注意 friendconst 吧,

  1. +=/-= 不能像 <,-,+.. 一样加 const或许是因为值修改了?
  2. 重载cin/cout的函数声明需要加 friend 并把函数体写到类的外面,其实感觉类里只写声明然后把所有函数体都写到外面蛮舒服的。
  3. 重载cin 不能加 const, 重载cout 最好加上 const ,好像是因为什么 const为常饮用,既可以引用左值也可以引用右值,总之能加const就加就对了
  4. ++,-- 还分前自增后自增,没搞懂那函数是啥意思,懒。反正照着网上抄就对了

题目

在这里插入图片描述

Input
21 10 35
10 15 25
Output
07:26:00
21:10:34
10:15:27
07:26:01
21:10:32
10:15:29

Code

#include <bits/stdc++.h>
using namespace std;
class Time {
private:int h, m, s;    //小时分钟秒
public:Time operator ++();//前置型Time operator ++(int);//后置型Time operator --();//前置型Time operator --(int);//后置型friend istream & operator >> (istream &in,Time &a);friend ostream & operator << (ostream &out,const Time &a);Time& operator += (const Time &b) {s += b.s;m += b.m;h += b.h;if(s > 59) {s -= 60;m++;}if(m > 59) {m -= 60;h++;}if(h > 23)h -= 24;return *this;}Time& operator -= (const Time &b) {s -= b.s;m -= b.m;h -= b.h;if(s < 0) {s += 60;m--;}if(m < 0) {m += 60;h--;}if(h < 0)h += 24;return *this;}Time Dec() {    //--s--;if(s < 0) {s += 60;m--;}if(m < 0) {m += 60;h--;}if(h < 0)h += 24;return (*this);}Time Inc() {    //--s++;if(s > 59) {s -= 60;m++;}if(m > 59) {m -= 60;h++;}if(h > 23)h -= 24;return (*this);}
}t;
Time Time::operator ++ (){    //前置++return Inc();
}
Time Time::operator ++ (int){    //后置++Time p = *this;Inc();return p;
}
Time Time::operator -- (){    //前置--return Dec();
}
Time Time::operator -- (int){    //后置--Time p = *this;Dec();return p;
}
istream & operator >> (istream &in,Time &a) {in >> a.h >> a.m >> a.s;return in;
}
ostream & operator << (ostream &out,const Time &a) {if(a.h < 10) out << '0';out << a.h << ':';if(a.m < 10) out << '0';out << a.m << ':';if(a.s < 10) out << '0';out << a.s;return out;
}
void solve() {Time t1, t2;cin >> t1 >> t2;cout << (t1 += (t2++)) << endl;cout << (t1 -= t2) << endl;cout << ++t2 << endl;cout << (t2 += (t1--)) << endl;cout << --t1 << endl;cout << (t2 -= t1) << endl;
}
signed main() {ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//    int T; scanf("%d", &T); while(T--)
//    int T; cin >> T; while(T--)solve();return 0;
}
http://www.jmfq.cn/news/5177035.html

相关文章:

  • 唐山网站建设服务/seo优化外包公司
  • 企业做网站有什么好处坏处/短视频优化
  • WordPress更改网站地址/seo商城
  • 音乐网站建设规划书/搜索引擎关键词怎么优化
  • 一起做网店网站靠谱么/长沙seo关键词
  • 网络推广运营的技巧/南宁seo外包要求
  • 网站推广策划的思路/天津seo霸屏
  • 做网站有2个前提条件_一个是网站/唐山网站建设方案优化
  • 做资料上哪个网站好/手游代理加盟哪个平台最强大
  • 安吉做网站/百度正版下载并安装
  • 忻府区最新疫情/360优化大师最新版的功能
  • 设计自己的名字图画/seoul怎么读
  • 为什么做独立站的人都不止一个网站/汕头网站建设
  • 企业网站制作教程视频/营销型网站的公司
  • 上海做网站推荐/谷歌海外推广
  • 做网站做推广/百度seo优化怎么做
  • 网站建站案例/南阳网站seo
  • 专业营销的网站建设公司/软文写作案例
  • 做招聘长图用什么网站/免费顶级域名注册
  • 北京酒店团购网站建设/营销网站有哪些
  • 里水九江网站建设/郑州网络推广公司排名
  • php 做视频网站/百度账号登录官网
  • wordpress一键拨号/沈阳关键字优化公司
  • 可以用AI做网站上的图吗/滁州网站seo
  • win系统安装wordpress/百度seo查询
  • 深圳福田大型商城网站建设/厦门网站推广公司哪家好
  • 某俄文网站/必应搜索引擎下载
  • 福建泉州网站建设公司哪家好/seo推广任务小结
  • 新乡百度网站推广工具/百度刷排名优化软件
  • 三亚文明城市建设服务中心报名网站/苏州seo优化