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

【C++手撕系列】——设计日期类实现日期计算器

【C++手撕系列】——设计日期类实现日期计算器😎

  • 前言🙌
    • C嘎嘎类中六大护法实现代码:
      • 获取每一个月天数的函数源码分享
      • 构造函数源码分享
      • 拷贝构造函数源码分享
      • 析构函数源码分享
      • 赋值运算符重载函数源码分享
      • 取地址和const取地址运算符重载函数源码分享
      • 各种比较(> , >= ,< , <= , == , !=)运算符重载函数源码分享
      • 各种运算的 运算符重载函数源码分享
      • 流插入(cout)和流提取(cin)运算符重载函数源码分享
      • 日期 - 日期 函数源码分享
    • Date 日期类头文件源码:
    • Date 日期类功能文件源码:
    • Date 日期类测试文件源码:
    • 测试截图证明:
      • TestDate1函数的测试结果
      • TestDate2函数的测试结果![在这里插入图片描述](https://img-blog.csdnimg.cn/f38c9207a79a4ef98f9eb94b84c7e049.png)
      • TestDate3函数的测试结果
      • TestDate4函数的测试结果
    • 小结语:
  • 总结撒花💞

追梦之旅,你我同行

   
😎博客昵称:博客小梦
😊最喜欢的座右铭:全神贯注的上吧!!!
😊作者简介:一名热爱C/C++,算法等技术、喜爱运动、热爱K歌、敢于追梦的小博主!

😘博主小留言:哈喽!😄各位CSDN的uu们,我是你的博客好友小梦,希望我的文章可以给您带来一定的帮助,话不多说,文章推上!欢迎大家在评论区唠嗑指正,觉得好的话别忘了一键三连哦!😘
在这里插入图片描述

前言🙌

    哈喽各位友友们😊,我今天又学到了很多有趣的知识现在迫不及待的想和大家分享一下! 都是精华内容,可不要错过哟!!!😍😍😍

    最近学习了C++的类和对象这部分的内容,然后自己手痒痒,就在空闲的时候手撕了一个日期类,按照网页版日期计算器有的功能进行一个一一的实现。纯粹分享,如果大家对日期计算器感兴趣的话也可以去实现一个自己的日期计算器,也可以借鉴我写的代码,有不懂的也可以来问我哦~废话不多说,咋们开始啦!!!

C嘎嘎类中六大护法实现代码:

在C嘎嘎中,有六大护法一直守护我们的类。分别是:

  • 构造函数
  • 析构函数
  • 拷贝构造函数
  • 赋值运算符重载函数
  • 取地址重载函数
  • const取地址重载函数

获取每一个月天数的函数源码分享

这里要注意的就是闰年和平年的2月天数的确定。闰年2月是29,平年是28天。

//获取每一个月的天数
int Date::GetMonthDay(int year, int month) const
{int DateArray[13] = { 0, 31,28,31,30,31,30,31,31,30,31,30,31 };if (month == 2 && ((year % 4 == 0 && year % 100 != 0)|| (year % 400 == 0))){return 29;}return DateArray[month];
}

构造函数源码分享

这里需要注意的就是输入非法日期的情况,所以这里要给个检查,当输入非法日期就报错!!!

//构造函数
Date:: Date(int year, int month , int day):_year(year),_month(month),_day(day)
{if (month < 1 || month > 12 || day < 1|| day > GetMonthDay(_year, _month)){cout << "输入日期非法" << endl;}
}

拷贝构造函数源码分享

这里可以不用写拷贝构造,编译器可以默认生成。

//拷贝构造函数
Date:: Date(const Date& d):_year(d._year), _month(d._month), _day(d._day)
{}

析构函数源码分享

这里可以不用写析构,编译器可以默认生成。

//析构函数
Date:: ~Date()
{}

赋值运算符重载函数源码分享

这里要避免 d1 = d1(自己给自己赋值)情况,所以加一个检查。其实也不用自己显示实现,编译器默认生成的赋值重载函数就可以了满足需求了~

//赋值运算符重载
Date& Date::operator=(const Date& d)
{if (this != &d){_year = d._year;_month = d._month;_day = d._day;}return *this;
}

取地址和const取地址运算符重载函数源码分享

一般这两个函数不用写,编译器默认生成的就可以了。这里知识闲着无聊先出来看看而已。

//取地址和const取地址运算符重载
Date* Date:: operator&()
{return this;
}const Date* Date:: operator&()const
{return this;
}

各种比较(> , >= ,< , <= , == , !=)运算符重载函数源码分享


//d1 < d2
bool Date::operator<(const Date& d) const
{if (_year < d._year){return true;}else if (_year == d._year && _month < d._month){return true;}else if (_year == d._year && _month == d._month && _day < d._day){return true;}else{return false;}
}//d1 == d2
bool Date::operator==(const Date& d) const
{if (_year == d._year && _month == d._month&& _day == d._day){return true;}return false;
}//d1 <= d2
bool Date::operator<=(const Date& d) const
{return (*this < d) || (*this == d);
}//d1 > d2
bool Date::operator>(const Date& d) const
{return !((*this) <= d);
}//d1 >= d2
bool Date::operator>=(const Date& d) const
{return !((*this) < d);
}//d1 != d2
bool Date::operator!=(const Date& d) const
{return !((*this) == d);
}

各种运算的 运算符重载函数源码分享

这里写好了+= ,然后复用 += 实现 + ;同理,写好了 -= ,我们就可以复用 -= 来实现 - 。前置++和后置++,区别是后置++参数列表加一个int进行占位,用于区分前置和后置++;同理前置- -与后置- -也是这样规定实现的。

// d1 += d2
Date& Date::operator+=(int day)
{if (day < 0){return (*this) -= -(day);}_day += day;//天满了进月while (_day > GetMonthDay(_year, _month)){_day -= GetMonthDay(_year, _month);++_month;//月满了进年if (_month == 13){++_year;_month = 1;}}return *this;
}Date Date::operator+(int day) const
{Date tem(*this);tem += day;return tem;
}Date& Date::operator-=(int day)
{if (day < 0){return (*this) += -(day);}_day -= day;while (_day <= 0){--_month;if (_month == 0){--_year;_month = 12;}_day += GetMonthDay(_year, _month);}return *this;
}Date Date::operator-(int day) const
{Date tem(*this);tem -= day;return tem;
}Date& Date::operator++()
{*this += 1;return *this;
}Date Date::operator++(int)
{Date tem(*this);++(*this);return tem;
}
Date& Date::operator--()
{(*this) -= 1;return *this;
}
Date Date::operator--(int)
{Date tem(*this);(*this) -= 1;return tem;
}

流插入(cout)和流提取(cin)运算符重载函数源码分享


ostream& operator<< (ostream& out,const Date& d)
{out << d._year << "/" << d._month << "/" << d._day << endl;return out;
}istream& operator>>(istream& in, Date& d)
{in >> d._year;in >> d._month;in >> d._day;return in;
}

日期 - 日期 函数源码分享

这个函数实现比较难想出来。这里先是确定出两个日期的大小关系,然后让小的日期不断++,n记录加的次数(也就是两个日期相隔的天数,当两个日期相等时,n*flag 就是结果。这里的flag是一个关键,当一开始是小日期 - 大日期时,flag 就是-1,计算出的答案自然是负数;当是大日期减小日期,flag就是1,答案自然就是正数。

int Date::operator-(const Date& d) const
{Date max = *this;Date min = d;int flag = 1;if (*this < d){max = d;min = *this;flag = -1;}int n = 0;while (min != max){++min;++n;}return n * flag;
}

Date 日期类头文件源码:

#pragma once#include<iostream>
using namespace std;class Date
{// 友元声明friend ostream& operator<<(ostream& out, const Date& d);friend istream& operator>>(istream& in, Date& d);public:int GetMonthDay(int year, int month) const;Date(int year = 1, int month = 1, int day = 1);//void Print() const;Date(const Date& d);~Date();// 只读函数可以加const,内部不涉及修改成员的都是只读函数bool operator<(const Date& d) const;bool operator==(const Date& d) const;bool operator<=(const Date& d) const;bool operator>(const Date& d) const;bool operator>=(const Date& d) const;bool operator!=(const Date& d) const;Date& operator+=(int day);Date operator+(int day) const;Date& operator-=(int day);Date operator-(int day) const;// 函数重载// 运算符重载// ++d1 -> d1.operator++()Date& operator++();// d1++ -> d1.operator++(0)// 加一个int参数,进行占位,跟前置++构成函数重载进行区分// 本质后置++调用,编译器进行特殊处理Date operator++(int);Date& operator--();Date operator--(int);Date& operator=(const Date& d);int operator-(const Date& d) const;// 日常自动生成的就可以// 不想被取到有效地址Date* operator&();const Date* operator&() const;
private:int _year;int _month;int _day;
};ostream& operator<<(ostream& out, const Date& d);
istream& operator>>(istream& in, Date& d);

Date 日期类功能文件源码:

#define _CRT_SECURE_NO_WARNINGS 1
#include"Date.h"//获取每一个月的天数
int Date::GetMonthDay(int year, int month) const
{int DateArray[13] = { 0, 31,28,31,30,31,30,31,31,30,31,30,31 };if (month == 2 && ((year % 4 == 0 && year % 100 != 0)|| (year % 400 == 0))){return 29;}return DateArray[month];
}//构造函数
Date:: Date(int year, int month , int day):_year(year),_month(month),_day(day)
{if (month < 1 || month > 12 || day < 1|| day > GetMonthDay(_year, _month)){cout << "输入日期非法" << endl;}
}//拷贝构造函数
Date:: Date(const Date& d):_year(d._year), _month(d._month), _day(d._day)
{}//析构函数
Date:: ~Date()
{}//赋值运算符重载
//避免 d1 = d1(自己给自己赋值)情况
Date& Date::operator=(const Date& d)
{if (this != &d){_year = d._year;_month = d._month;_day = d._day;}return *this;
}//取地址和const取地址运算符重载
Date* Date:: operator&()
{return this;
}const Date* Date:: operator&()const
{return this;
}//d1 < d2
bool Date::operator<(const Date& d) const
{if (_year < d._year){return true;}else if (_year == d._year && _month < d._month){return true;}else if (_year == d._year && _month == d._month && _day < d._day){return true;}else{return false;}
}//d1 == d2
bool Date::operator==(const Date& d) const
{if (_year == d._year && _month == d._month&& _day == d._day){return true;}return false;
}//d1 <= d2
bool Date::operator<=(const Date& d) const
{return (*this < d) || (*this == d);
}//d1 > d2
bool Date::operator>(const Date& d) const
{return !((*this) <= d);
}//d1 >= d2
bool Date::operator>=(const Date& d) const
{return !((*this) < d);
}//d1 == d2
bool Date::operator!=(const Date& d) const
{return !((*this) == d);
}// d1 += d2
Date& Date::operator+=(int day)
{if (day < 0){return (*this) -= -(day);}_day += day;//天满了进月while (_day > GetMonthDay(_year, _month)){_day -= GetMonthDay(_year, _month);++_month;//月满了进年if (_month == 13){++_year;_month = 1;}}return *this;
}Date Date::operator+(int day) const
{Date tem(*this);tem += day;return tem;
}Date& Date::operator-=(int day)
{if (day < 0){return (*this) += -(day);}_day -= day;while (_day <= 0){--_month;if (_month == 0){--_year;_month = 12;}_day += GetMonthDay(_year, _month);}return *this;
}Date Date::operator-(int day) const
{Date tem(*this);tem -= day;return tem;
}ostream& operator<< (ostream& out,const Date& d)
{out << d._year << "/" << d._month << "/" << d._day << endl;return out;
}istream& operator>>(istream& in, Date& d)
{in >> d._year;in >> d._month;in >> d._day;return in;
}Date& Date::operator++()
{*this += 1;return *this;
}Date Date::operator++(int)
{Date tem(*this);++(*this);return tem;
}
Date& Date::operator--()
{(*this) -= 1;return *this;
}
Date Date::operator--(int)
{Date tem(*this);(*this) -= 1;return tem;
}int Date::operator-(const Date& d) const
{Date max = *this;Date min = d;int flag = 1;if (*this < d){max = d;min = *this;flag = -1;}int n = 0;while (min != max){++min;++n;}return n * flag;
}

Date 日期类测试文件源码:

#define _CRT_SECURE_NO_WARNINGS 
#include"Date.h"//6大默认成员函数测试
void TestDate1()
{//构造测试Date d1;//拷贝构造测试Date d2(2023, 8, 11);//流插入运算符重载测试cout << d1;cout << d2;//流提取运算符重载测试cin >> d1;cout << d1;//取地址运算符重载测试cout << &d1 << endl;cout << &d2;}//测试日期大小比较以及计算日期往后或者往前几天的日期是多少
void TestDate2()
{Date d1(2003, 8, 23);Date d2(2023, 8, 11);/*cout << (d1 < d2) << endl;cout << (d1 <= d2) << endl;cout << (d1 > d2) << endl;cout << (d1 >= d2) << endl;cout << (d1 == d2) << endl;cout << (d1 != d2) << endl;*///cout << d1;//d1 += 10000;//cout << d1;//d2 = d1 + 10000;//cout << d1;//cout << d2;//d1 += -1000;//cout << d1;//d1 = d2 + -1000;//cout << d1;/*d1 -= 11000;d2 = d1 - 1000;cout << d1;cout << d2;*/}void TestDate3()
{Date d1(2003, 8, 23);Date d2(2023, 8, 11);/*cout << d1;++d1;cout << d1;*//*cout << d1;d2 = d1++;cout << d1;cout << d2;*//*cout << d1;d2 = d1--;cout << d1;cout << d2;*//*cout << d1;d2 = ++d1;cout << d1;cout << d2;*//*cout << d1;d2 = --d1;cout << d1;cout << d2;*/
}void TestDate4()
{Date d1(2003, 8, 23);Date d2(2023, 8, 11);cout << (d2 - d1) << endl;cout << (d1 - d2) << endl;
}int main()
{//TestDate1();//TestDate2();//TestDate3();TestDate4();return 0;
}

测试截图证明:

TestDate1函数的测试结果

在这里插入图片描述

TestDate2函数的测试结果在这里插入图片描述

TestDate3函数的测试结果

在这里插入图片描述

TestDate4函数的测试结果

在这里插入图片描述
与网页版日期计算器测试结果一致!!!!!
在这里插入图片描述

小结语:

上述测试案例我只写了比较常规的,并没有做会更加仔细的测试。大家也可以帮我用链接: 网页版日期计算器测试一下我的程序有没有bug,我好及时更正!!!

总结撒花💞

   本篇文章旨在分享的是用C++ 设计日期类实现日期计算器的知识。希望大家通过阅读此文有所收获
   😘如果我写的有什么不好之处,请在文章下方给出你宝贵的意见😊。如果觉得我写的好的话请点个赞赞和关注哦~😘😘😘

相关文章:

【C++手撕系列】——设计日期类实现日期计算器

【C手撕系列】——设计日期类实现日期计算器&#x1f60e; 前言&#x1f64c;C嘎嘎类中六大护法实现代码&#xff1a;获取每一个月天数的函数源码分享构造函数源码分享拷贝构造函数源码分享析构函数源码分享赋值运算符重载函数源码分享取地址和const取地址运算符重载函数源码分…...

FFmpeg常见命令行(四):FFmpeg流媒体

前言 在Android音视频开发中&#xff0c;网上知识点过于零碎&#xff0c;自学起来难度非常大&#xff0c;不过音视频大牛Jhuster提出了《Android 音视频从入门到提高 - 任务列表》&#xff0c;结合我自己的工作学习经历&#xff0c;我准备写一个音视频系列blog。本文是音视频系…...

ftp访问ubuntu文件系统

ftp访问ubuntu文件系统 安装vsftpd服务器 sudo apt-get install vsftpd启动ftp服务 sudo service vsftpd start编辑vsftdp的配置文件 sudo vim /etc/vsftpd.conf找到write_enable字段并修改, 设定可以进行写操作,保存并退出 write_enable=YES从新启动ftp服务...

网络防御(6)

密码学综合应用 定义&#xff1a; 密码学综合应用是指将密码学的理论和技术应用于各种场景中&#xff0c;以保障信息的安全性、完整性和可靠性。密码学的应用范围非常广泛&#xff0c;包括通信安全、网络安全、电子商务、数字签名、认证、密钥管理等。 密码学综合应用的实例…...

【Nginx15】Nginx学习:HTTP核心模块(十二)内嵌变量

Nginx学习&#xff1a;HTTP核心模块&#xff08;十二&#xff09;内嵌变量 关于内嵌变量&#xff0c;其实就是 Nginx 开放给我们的在配置文件中可以使用的变量。源码中无非就是替换成真实的代码变量进行操作。这些变量可以帮助我们做很多事情。之前的文章中其实也有不少地方用到…...

2023年中国HPV宫颈癌疫苗需求量、竞争格局、市场规模及行业细分产品规模分析[图]

HPV宫颈癌疫苗也是人乳头瘤病毒疫苗&#xff0c;由重组表达的HPV主要衣壳蛋白L1病毒样颗粒制备而成&#xff0c;可以预防由HPV感染及其引起的各种疾病&#xff0c;包括宫颈癌、阴道癌、肛门癌和口咽癌等癌症&#xff0c;及相关癌前病变。 目前中国在售的HPV疫苗包括万泰生物的二…...

基于LMK2572的FPGA逻辑实现

项目背景: 在时钟同步或类似时钟方案系统,需要用到一些时钟芯片,LMK2572就是一款频率带宽覆盖广的芯片。 项目介绍: LMK2572该器件是一个低功耗、高性能的宽带合成器,可生成 13MHz 到 6.4GHz 的任何频率,而无需使用内部倍频器。该 PLL 可提供优异的性能,而 3.3V 单电源…...

数据通信——VRRP

引言 之前把实验做了&#xff0c;结果发现我好像没有写过VRRP的文章&#xff0c;连笔记都没记过。可能是因为对STP的记忆&#xff0c;导致现在都没忘太多。 一&#xff0c;什么是VRRP VRRP全名是虚拟路由冗余协议&#xff0c;虚拟路由&#xff0c;看名字就知道这是运行在三层接…...

第二章:CSS基础进阶-part2:CSS过渡与动画

文章目录 CSS3 过渡动画一、transition属性二、transform属性-2D变换2.1 tanslate &#xff1a; 移动2.2 rotate-旋转2.3 scale-变形2.4 skew-斜切2.5 transform-origin: 变换中心点设置 三、CSS3关键帧动画四、CSS3-3D变换4.1 perspective 定义3D元素距视图距离4.2 transform-…...

华为OD真题---玩牌高手--带答案

2023华为OD统一考试&#xff08;AB卷&#xff09;题库清单-带答案&#xff08;持续更新&#xff09;or2023年华为OD真题机考题库大全-带答案&#xff08;持续更新&#xff09; 玩牌高手 给定一个长度为n的整型数组&#xff0c;表示一个选手在n轮内可选择的牌面分数。选手基于规…...

案例14 Spring MVC文件上传案例

基于Spring MVC实现文件上传&#xff1a; 使用commons-fileupload实现上传文件到本地目录。 实现上传文件到阿里云OSS和从阿里云OSS下载文件到本地。 1. 创建项目 选择Maven快速构建web项目&#xff0c;项目名称为case14-springmvc03。 ​ 2. 配置Maven依赖 <?xml ver…...

如何用Python实现多线程

1 问题 线程是操作系统能够进行运算调度的最小单位。进程被包含在进程中&#xff0c;是进程中实际处理单位。一条线程就是一堆指令集合。一条线程是指进程中一个单一顺序的控制流&#xff0c;一个进程中可以并发多个线程&#xff0c;每条线程并行执行不同的任务。那么如何用pyt…...

Chrome浏览器导出插件并安装到其他电脑浏览器上的解决方案

大家好,我是爱编程的喵喵。双985硕士毕业,现担任全栈工程师一职,热衷于将数据思维应用到工作与生活中。从事机器学习以及相关的前后端开发工作。曾在阿里云、科大讯飞、CCF等比赛获得多次Top名次。现为CSDN博客专家、人工智能领域优质创作者。喜欢通过博客创作的方式对所学的…...

对话即数据分析,网易数帆ChatBI做到了

大数据产业创新服务媒体 ——聚焦数据 改变商业 在当今数字化快速发展的时代&#xff0c;数据已经成为业务经营与管理决策的核心驱要素。无论是跨国大企业还是新兴创业公司&#xff0c;正确、迅速地洞察数据已经变得至关重要。然而&#xff0c;传统的BI工具往往对用户有一定的…...

简单记录牛客top101算法题(初级题C语言实现)BM17 二分查找 BM21 旋转数组的最小数字 BM23 二叉树的前序遍历

1. BM17 二分查找 要求&#xff1a;给定一个 元素升序的、无重复数字的整型数组 nums 和一个目标值 target &#xff0c;写一个函数搜索 nums 中的 target&#xff0c;如果目标值存在返回下标&#xff08;下标从 0 开始&#xff09;&#xff0c;否则返回 -1。 输入&#xff1a…...

日常BUG——Java使用Bigdecimal类型报错

&#x1f61c;作 者&#xff1a;是江迪呀✒️本文关键词&#xff1a;日常BUG、BUG、问题分析☀️每日 一言 &#xff1a;存在错误说明你在进步&#xff01; 一、问题描述 直接上代码&#xff1a; Test public void test22() throws ParseException {System.out.p…...

为Windows Terminal设置背景图片

直接通过界面上选项无法达到修改背景图片的目的&#xff0c;后再在官网&#xff0c;和git上找到通过修改配置文件来更改背景图片 首先打开设置界面 点击左下角打开settings.json文件 在json中profiles关键字default选项相面增加几个key,就像下面 修改前修改后 修改后的termin…...

【Spring】-Spring中Bean对象的存取

作者&#xff1a;学Java的冬瓜 博客主页&#xff1a;☀冬瓜的主页&#x1f319; 专栏&#xff1a;【Framework】 主要内容&#xff1a;往spring中存储Bean对象的三大方式&#xff1a;XML方式(Bean标签)&#xff1b;五大类注解&#xff1b;方法注解。从spring中取对象的两种方式…...

机器人CPP编程基础-03变量类型Variables Types

机器人CPP编程基础-02变量Variables 全文AI生成。 C #include<iostream>using namespace std;main() {int a10,b35; // 4 bytescout<<"Value of a : "<<a<<" Address of a : "<<&a <<endl;cout<<"Val…...

或许有用的开源项目平台——物联网、区块链、商城、CMS、客服系统、低代码、可视化、ERP等

摘自个人印象笔记Evernote Export wumei-smart-物美智能开源物联网平台 官网&#xff1a;https://wumei.live/ gitee&#xff1a;https://gitee.com/kerwincui/wumei-smart 一个简单易用的物联网平台。可用于搭建物联网平台以及二次开发和学习。适用于智能家居、智慧办公、智慧…...

微信小程序之bind和catch

这两个呢&#xff0c;都是绑定事件用的&#xff0c;具体使用有些小区别。 官方文档&#xff1a; 事件冒泡处理不同 bind&#xff1a;绑定的事件会向上冒泡&#xff0c;即触发当前组件的事件后&#xff0c;还会继续触发父组件的相同事件。例如&#xff0c;有一个子视图绑定了b…...

JVM垃圾回收机制全解析

Java虚拟机&#xff08;JVM&#xff09;中的垃圾收集器&#xff08;Garbage Collector&#xff0c;简称GC&#xff09;是用于自动管理内存的机制。它负责识别和清除不再被程序使用的对象&#xff0c;从而释放内存空间&#xff0c;避免内存泄漏和内存溢出等问题。垃圾收集器在Ja…...

使用van-uploader 的UI组件,结合vue2如何实现图片上传组件的封装

以下是基于 vant-ui&#xff08;适配 Vue2 版本 &#xff09;实现截图中照片上传预览、删除功能&#xff0c;并封装成可复用组件的完整代码&#xff0c;包含样式和逻辑实现&#xff0c;可直接在 Vue2 项目中使用&#xff1a; 1. 封装的图片上传组件 ImageUploader.vue <te…...

Maven 概述、安装、配置、仓库、私服详解

目录 1、Maven 概述 1.1 Maven 的定义 1.2 Maven 解决的问题 1.3 Maven 的核心特性与优势 2、Maven 安装 2.1 下载 Maven 2.2 安装配置 Maven 2.3 测试安装 2.4 修改 Maven 本地仓库的默认路径 3、Maven 配置 3.1 配置本地仓库 3.2 配置 JDK 3.3 IDEA 配置本地 Ma…...

LabVIEW双光子成像系统技术

双光子成像技术的核心特性 双光子成像通过双低能量光子协同激发机制&#xff0c;展现出显著的技术优势&#xff1a; 深层组织穿透能力&#xff1a;适用于活体组织深度成像 高分辨率观测性能&#xff1a;满足微观结构的精细研究需求 低光毒性特点&#xff1a;减少对样本的损伤…...

libfmt: 现代C++的格式化工具库介绍与酷炫功能

libfmt: 现代C的格式化工具库介绍与酷炫功能 libfmt 是一个开源的C格式化库&#xff0c;提供了高效、安全的文本格式化功能&#xff0c;是C20中引入的std::format的基础实现。它比传统的printf和iostream更安全、更灵活、性能更好。 基本介绍 主要特点 类型安全&#xff1a…...

水泥厂自动化升级利器:Devicenet转Modbus rtu协议转换网关

在水泥厂的生产流程中&#xff0c;工业自动化网关起着至关重要的作用&#xff0c;尤其是JH-DVN-RTU疆鸿智能Devicenet转Modbus rtu协议转换网关&#xff0c;为水泥厂实现高效生产与精准控制提供了有力支持。 水泥厂设备众多&#xff0c;其中不少设备采用Devicenet协议。Devicen…...

ZYNQ学习记录FPGA(一)ZYNQ简介

一、知识准备 1.一些术语,缩写和概念&#xff1a; 1&#xff09;ZYNQ全称&#xff1a;ZYNQ7000 All Pgrammable SoC 2&#xff09;SoC:system on chips(片上系统)&#xff0c;对比集成电路的SoB&#xff08;system on board&#xff09; 3&#xff09;ARM&#xff1a;处理器…...

前端开发者常用网站

Can I use网站&#xff1a;一个查询网页技术兼容性的网站 一个查询网页技术兼容性的网站Can I use&#xff1a;Can I use... Support tables for HTML5, CSS3, etc (查询浏览器对HTML5的支持情况) 权威网站&#xff1a;MDN JavaScript权威网站&#xff1a;JavaScript | MDN...

Java数组Arrays操作全攻略

Arrays类的概述 Java中的Arrays类位于java.util包中&#xff0c;提供了一系列静态方法用于操作数组&#xff08;如排序、搜索、填充、比较等&#xff09;。这些方法适用于基本类型数组和对象数组。 常用成员方法及代码示例 排序&#xff08;sort&#xff09; 对数组进行升序…...