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

【C++】类和对象之日期类的实现(构造、运算符重载)

文章目录

  • 一、日期类要实现的函数
  • 二、函数实现
    • 1、GetMonthDay获取对应月份的天数
    • 2、CheckDate检查日期
    • 3、Date构造函数
    • 4、Print打印日期
    • 5、运算符重载
      • 1. += 、+、-=、-
      • 2. 前置++/--、后置++/--
      • 3. 两个日期类相减(求相差日期)
    • 6、比较
    • 7、流插入、流提取(输入输出)
  • 三、完整代码
  • 三、谢谢观看!

一、日期类要实现的函数

类名为Date

bool CheckDate(); //检查所用日期是否合法(有无越界)Date(int year = 1, int month = 1, int day = 1);//全缺省构造函数(初始化)Date(const Date& d);  //拷贝构造int GetMonthDay(int year, int month);//获取某年某月的天数void Print() const;//打印日期//运算符重载Date& operator+=(int day);
Date operator+(int day) const;// 加const后第一个参数变为了const Date* const this (第一个const),this指向的内容就不能被改变
Date& operator-=(int day);
Date operator-(int day) const;//++d1(前置加加)
Date operator++();
//d1++(后置加加)为了区分前置和后置加加,规定后置加加要有形参
Date operator++(int);
//--d1
Date operator--();
//d1--
Date operator--(int);
//d1-d2
int 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;
bool operator>(const Date& d) const;//流插入
ostream& operator<<(ostream& out, const Date& d);
//流提取
istream& operator>>(istream& in, Date& d);

二、函数实现

若函数写在类的外面,要在函数名前面加 类名::,在Date类中,为Date::

1、GetMonthDay获取对应月份的天数

//获取某年某月的天数
int GetMonthDay(int year, int month)
{	//断言,确保月份合法	assert(month > 0 && month < 13);//下标对应月份                      1  2 3  4  5  6  7  8  9  10 11 12static int getmonthDay[13] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };  //因为该函数(GetMonthDay)会被频繁调用,即会频繁创建数组,将数组放在静态区(static)更好//闰年二月有29天if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))return 29;return getmonthDay[month];
}

2、CheckDate检查日期

判断month是否在1~12之间,以及该月对应的天数是否符合

//检查传的日期是否正确
bool Date::CheckDate()
{if (_month < 1 || _month>12 || _day <1 || _day>GetMonthDay(_year, _month))return false;elsereturn true;
}

3、Date构造函数

//全缺省构造
Date::Date(int year, int month, int day)
{_year = year;_month = month;_day = day;if (!CheckDate()){cout << "非法日期:" << endl;Print();}}//拷贝构造
Date::Date(const Date& d)
{//将d拷贝给要构造的对象_year = d._year;_month = d._month;_day = d._day;
}

4、Print打印日期

void Date::Print() const
{cout << _year << "/" << _month << "/" << _day << endl;
}

5、运算符重载

1. += 、+、-=、-


//d1+=day(将d1直接改变了)
Date& Date::operator+=(int day)
{//day可能为负if (day < 0){return *this -= (-day);}_day += day;while (_day > GetMonthDay(_year, _month)){_day -= GetMonthDay(_year, _month);_month++;if (_month == 13){_month = 1;_year ++;}}return *this;
}//d1+day(d1的值不变)
Date Date::operator+(int day) const
{Date tmp = *this;//拷贝构造tmp += day;return tmp;
}//d1-=day(d1被改变了)
Date& Date::operator-=(int day)
{//day可能为负if (day < 0){return *this += (-day);}//用-=复用-//*this = *this-day;//return *this;_day -= day;while (_day <= 0) //_day>0合法{_month--;//_month为1月if (_month == 0){_month = 12;_year--;}_day += GetMonthDay(_year, _month);}return *this;
}
//d1-day(d1不变)
Date Date::operator-(int day) const
{Date tmp = *this;tmp -= day;return tmp;
}

2. 前置++/–、后置++/–

//++d1(表达式++d1的值改变,但d1自增)
Date Date::operator++()
{*this += 1;return *this;
}
//d1++(表达式d1++的值不变,但d1自增)
Date Date::operator++(int)
{Date tmp = *this;*this += 1;return tmp; //表达式的值不变,但d1自增
}Date Date::operator--()
{*this -= 1;return *this;
}
Date Date::operator--(int)
{Date tmp = *this;*this -= 1;return tmp;
}

3. 两个日期类相减(求相差日期)

//d1-d2
int Date::operator-(const Date& d)const
{int n = 0;int flag = 1;Date max = *this;Date min = d;if (*this < d){max = d;min = *this;flag = -1;}while (min != max){++min; ++n;}return n * flag;  //如果d1>d2 ,flag=1,天数相差为正数//如果d1<d2 ,flag=-1,天数相差为负数
}

6、比较

//写两个比较运算符重载,剩下的都可以通过复用这两个来完成
bool Date::operator<(const Date& d)const
{if (_year < d._year){return true;}else if (_year == d._year){if (_month < d._month)return true;else if (_month == d._month)return _day < d._day;}return false;//剩下的全为false
}
bool Date::operator==(const Date& d)const
{return _year == d._year && _month == d._month && _day == d._day;
}bool Date::operator<=(const Date& d)const
{ // d1<=d2  即 *this<=dreturn *this < d || *this == d;
}
bool Date::operator>(const Date& d)const
{return !(*this <= d);
}
bool Date::operator>=(const Date& d)const
{return *this > d || *this == d;
}
bool Date::operator!=(const Date& d)const
{return  _year != d._year || _month != d._month || _day != d._day;
}

7、流插入、流提取(输入输出)

若重载函数写在类的外面,要在类中加入友元函数声明,使其可以访问类的成员变量(private)

//友元函数声明
friend ostream& operator<<(ostream& out, const Date& d);
friend istream& operator>>(istream& in, Date& d);
//流插入
ostream& operator<<(ostream& out, const Date& d)
{out << d._year << "年" << d._month << "月" << d._day << "日" << endl; return out;//能够连续打印
}    //cout << d1 << d2;流插入是从左往右赋值//返回out后,相当于将cout<<d1变为了out,此时,变为了out<<d2 ,进而将d2打印出来了!//流提取
istream& operator>>(istream& in, Date& d)
{有非法日期时无法判断//cout << "请依次输入年月日:>";//in >> d._year >> d._month >> d._day;while (1){cout << "请依次输入年月日:>";in >> d._year >> d._month >> d._day;if (!d.CheckDate()){cout << "该输入日期非法:";d.Print();cout << "请重新输入!!!" << endl;}elsebreak;}return in;
}

三、完整代码

#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<assert.h>
using namespace std;class Date
{//友元函数声明friend ostream& operator<<(ostream& out, const Date& d);friend istream& operator>>(istream& in, Date& d);
public:bool CheckDate();//全缺省构造函数Date(int year = 1, int month = 1, int day = 1);//打印void Print() const;//拷贝构造Date(const Date& d);//获取某年某月的天数(直接在头文件中写,默认是内联函数inline)int GetMonthDay(int year, int month){		assert(month > 0 && month < 13);//下标对应月份                      1  2 3  4  5  6  7  8  9  10 11 12static int getmonthDay[13] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };  //因为该函数会被频繁调用,即会频繁创建数组,要放在静态区更好static//闰年二月有29天if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))return 29;return getmonthDay[month];}//日期的加、减Date& operator+=(int day);Date operator+(int day) const;// 加const后第一个参数变为了const Date* const this (第一个const),this指向的内容就不能被改变Date& operator-=(int day);Date operator-(int day) 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;//前/后置 ++//后置++增加一个int形参(实际上编译器并不接收该形参),与前置++构成函数重载//++d1Date operator++();//d1++Date operator++(int);Date operator--();Date operator--(int);//d1-d2int operator-(const Date& d) const;//流插入运算符重载  ,不符合用户习惯//void operator<<(ostream& out); 
private:int _year;int _month;int _day;};//检查传的日期是否正确
bool Date::CheckDate()
{if (_month < 1 || _month>12 || _day <1 || _day>GetMonthDay(_year, _month))return false;elsereturn true;
}
//全缺省构造
Date::Date(int year, int month, int day)
{_year = year;_month = month;_day = day;if (!CheckDate()){cout << "非法日期:" << endl;Print();}}
//拷贝构造
Date::Date(const Date& d)
{//将d拷贝给要构造的对象_year = d._year;_month = d._month;_day = d._day;
}void Date::Print() const
{cout << _year << "/" << _month << "/" << _day << endl;
}//d1+=day(将d1直接改变了)
Date& Date::operator+=(int day)
{//day可能为负if (day < 0){return *this -= (-day);}_day += day;while (_day > GetMonthDay(_year, _month)){_day -= GetMonthDay(_year, _month);_month++;if (_month == 13){_month = 1;_year ++;}}return *this;
}//d1+day(这里的d1不变)
Date Date::operator+(int day) const
{Date tmp = *this;//拷贝构造tmp += day;return tmp;
}Date& Date::operator-=(int day)
{//day可能为负if (day < 0){return *this += (-day);}//用-=复用-//*this = *this-day;//return *this;_day -= day;while (_day <= 0) //_day>0合法{_month--;//_month为1月if (_month == 0){_month = 12;_year--;}_day += GetMonthDay(_year, _month);}return *this;
}
Date Date::operator-(int day) const
{Date tmp = *this;tmp -= day;return tmp;
}bool Date::operator<(const Date& d)const
{if (_year < d._year){return true;}else if (_year == d._year){if (_month < d._month)return true;else if (_month == d._month)return _day < d._day;}return false;//剩下的全为false
}
bool Date::operator==(const Date& d)const
{return _year == d._year && _month == d._month && _day == d._day;
}
bool Date::operator!=(const Date& d)const
{return  _year != d._year || _month != d._month || _day != d._day;
}
bool Date::operator<=(const Date& d)const
{ // d1<=d2  即 *this<=dreturn *this < d || *this == d;
}
bool Date::operator>(const Date& d)const
{return !(*this <= d);
}
bool Date::operator>=(const Date& d)const
{return *this > d || *this == d;
}//++d1
Date Date::operator++()
{*this += 1;return *this;
}
//d1++
Date Date::operator++(int)
{Date tmp = *this;*this += 1;return tmp; //表达式的值不变,但d1自增
}
Date Date::operator--()
{*this -= 1;return *this;
}
Date Date::operator--(int)
{Date tmp = *this;*this -= 1;return tmp;
}//d1-d2
int Date::operator-(const Date& d)const
{int n = 0;int flag = 1;Date max = *this;Date min = d;if (*this < d){max = d;min = *this;flag = -1;}while (min != max){++min; ++n;}return n * flag;  //如果d1>d2 ,flag=1,天数相差为正数//如果d1<d2 ,flag=-1,天数相差为负数
}//void Date::operator<<(ostream& out)
//{
//	out << _year << "年" << _month << "月" << _day << "日" << endl;
//}ostream& operator<<(ostream& out, const Date& d)
{out << d._year << "年" << d._month << "月" << d._day << "日" << endl; return out;//能够连续打印
}    //cout << d1 << d2;流插入是从左往右赋值//返回out后,相当于将cout<<d1变为了out,此时,变为了out<<d2 ,进而将d2打印出来了!
istream& operator>>(istream& in, Date& d)
{有非法日期时无法判断//cout << "请依次输入年月日:>";//in >> d._year >> d._month >> d._day;while (1){cout << "请依次输入年月日:>";in >> d._year >> d._month >> d._day;if (!d.CheckDate()){cout << "该输入日期非法:";d.Print();cout << "请重新输入!!!" << endl;}elsebreak;}return in;
}//测试
//成员函数的const要放到参数列表的后面
void Test01()
{  //+= 、 +Date a(2025, 4, 13);Date tmp = a + 100;  //或 Date tmp(a+100);a.Print();tmp.Print();a += 10000;a.Print();
}
void Test02()
{  //-= 、 -Date a(2025, 4, 14);a -= 100;a.Print();
}void Test03()
{Date a(2025, 4, 14);Date b(2024, 4, 14);cout << (a < b) << endl;
}void Test04()
{Date a(2025, 4, 14);/*Date tmp1 = a++;a.Print();tmp1.Print();*/Date tmp2 = ++a;  // a.operator++();a.Print();tmp2.Print();
}void Test05()
{   //a、b相差多少天Date a(2025, 4, 15);Date b(2024, 4, 31);cout << (a - b) << endl;
}void Test06()
{Date d1;Date d2;//cout<<d1;//d1 << cout;//void operator<<(ostream & out); 参数列表有一个隐含的this指针,this为第一个参数,而out为第二个,故传参的时候,要将d1写在前面//cout << d1 << d2;//有return可以实现连续打印cin >> d1 >> d2;cout << d1 - d2 << endl;
}
int main()
{//Test01();//Test02();//Test03();Test06();return 0;
}

三、谢谢观看!

相关文章:

【C++】类和对象之日期类的实现(构造、运算符重载)

文章目录 一、日期类要实现的函数二、函数实现1、GetMonthDay获取对应月份的天数2、CheckDate检查日期3、Date构造函数4、Print打印日期5、运算符重载1. 、、-、-2. 前置/--、后置/--3. 两个日期类相减&#xff08;求相差日期&#xff09; 6、比较7、流插入、流提取&#xff0…...

【Rust 精进之路之第9篇-所有权·核心】规则与移动 (Move):Rust 内存安全基石详解

系列: Rust 精进之路:构建可靠、高效软件的底层逻辑 作者: 码觉客 发布日期: 2025年4月20日 引言:没有 GC,Rust 如何管好内存?答案是所有权! 在我们的 Rust 探索之旅中,我们已经学习了变量、数据类型、控制流、函数和强大的构建工具 Cargo。现在,我们将踏入 Rust 最…...

【任务调度】xxl-job入门

xxl- job 入门 附上笔者写的测视示例&#xff1a;chenmeng-test-demos/demo8-task/task-xxl-job at master cmty256/chenmeng-test-demos 官方文档 XXL-JOB官网 源码仓库地址&#xff1a; Github&#xff1a;https://github.com/xuxueli/xxl-job Gitee&#xff1a;http://g…...

Go语言--语法基础4--基本数据类型--浮点数类型

3 、浮点数类型 浮点型用于表示包含小数点的数据&#xff0c;比如 1.234 就是一个浮点型数据。 Go 语言中的浮点类型采用 IEEE-754 标准的表达方式。 float32 精度是小数点后 7 位 float64 精度是小数点后 15 位。 1. 浮点数表示 Go 语言定义了两个类型 float32 和 floa…...

秘密任务 3.0:如何通过 JWT 认证确保 WebSockets 安全

在之前的文章中&#xff0c;我们探讨了如何通过 WebSockets DTOs 设计实时操作。现在&#xff0c;我们迎来了一项新的挑战&#xff1a;确保 WebSocket 通信在任务执行过程中保持安全。如果敌方潜伏在我们的实时通信渠道中&#xff0c;机密情报可能会被泄露。 任务&#xff1a…...

UID和GID的区别

UID&#xff08;用户标识符&#xff09;和 GID&#xff08;组标识符&#xff09;是 Linux/Unix 系统中用于管理用户和组权限的核心机制&#xff0c;它们的区别主要体现在作用对象和用途上&#xff1a; 目录 1. 定义与作用对象 2. 主要用途 3. 系统保留范围 4. 用户与组的关…...

【网络】通过Samba实现Window挂在Linux服务器路径

有时候我们去进行内网部署时&#xff0c;会遇到客户或者甲方爸爸说&#xff0c;需要将Linux中的某个路径共享出去到Window上&#xff0c;挂载出比如Z:\这种盘符。通过打开Z盘&#xff0c;来查看服务器的指定目录下的数据。 步骤1&#xff1a; 在Linux中安装samba yum install…...

UE5 UI 教程系列全集

https://www.youtube.com/TheRoyalSkies/search?queryUnreal-5%20UI...

论文笔记(七十八)Do generative video models understand physical principles?

Do generative video models understand physical principles? 文章概括Physics-IQ基准数据集评估协议为什么要创建一个真实世界的Physics-IQ数据集模型物理理解的评估指标动作发生在哪里&#xff1f;空间IoU&#xff08;Spatial IoU&#xff09;动作在哪里、何时发生&#xf…...

Viper配置管理笔记

一、什么是 Viper&#xff1f; Viper 是 Go 语言的一个强大工具&#xff0c;就像一个超级管家&#xff0c;专门负责帮你打理程序的各种配置。它能把配置文件&#xff08;比如 JSON、YAML、TOML 等格式&#xff09;里的内容读出来&#xff0c;还能监控配置文件的变化&#xff0…...

visual studio无法跳转到函数定义、变量定义、跳转函数位置不准问题解决

参考&#xff1a;https://blog.csdn.net/snakehacker/article/details/135438353 程序有时会出现大部分函数都不能准确的从头文件中正确定位到函数定位,这是因为数据库错乱造成的,可以通过重构数据库来解决,操作方法如下&#xff1a; 菜单栏&#xff1a;工具——选项 文本编辑…...

【Rust 精进之路之第15篇-枚举 Enum】定义、变体与数据关联:表达多种可能性

系列: Rust 精进之路:构建可靠、高效软件的底层逻辑 作者: 码觉客 发布日期: 2025年4月20日 引言:当值拥有“选项”——超越结构体的表达力 在上一篇【结构体 Struct】中,我们学习了如何使用结构体将多个相关的数据字段组合成一个有意义的整体。结构体非常适合表示那些…...

C++ 相关系统软件简介与学习方法【最水的一期】

C 作为一种强大的C 相关系统软件简介编程语言&#xff0c;广泛应用于系统软件开发领域。以下为你介绍几款基于 C 开发的典型系统软件及其特点&#xff1a; 操作系统内核 部分操作系统内核采用 C 开发&#xff0c;例如某些嵌入式操作系统。C 的高性能、底层硬件访问能力和强大的…...

【Linux我做主】GDB调试工具完全指南

Linux下GDB调试工具完全指南&#xff1a;25个核心命令详解与实战示例 github地址 有梦想的电信狗 前言 GDB&#xff08;GNU Debugger&#xff09;是Linux开发中不可或缺的调试工具&#xff0c;尤其在定位代码逻辑错误和内存问题时表现卓越。本文基于实际开发经验&#xff0…...

基于SpringBoot3实现MyBatis-Plus(SSMP)整合快速入门CURD(增删改查)

目录 一、快速搭建SpringBoot-Web工程脚手架。 1.1 Spring Initializr 初始化工程。(官方提供) 1.2 工程脚手架初始化详细步骤。(IDEA2024.1.1) 二、MyBatis-Plus的特性与快速上手。 2.1 官网地址与基本特性。 2.2 快速上手技术栈基础。 2.3 Spring Boot2 的 MyBatis-Plus Star…...

短视频电商新纪元:TikTok Shop全球蓝海争夺战进入关键窗口期

一、流量重构&#xff1a;TikTok Shop改写全球电商版图 2024年&#xff0c;全球跨境电商市场迎来新一轮洗牌。当Temu、Shein等平台深陷“低价内卷”泥潭时&#xff0c;TikTok Shop凭借日均30亿次的短视频流量&#xff0c;正在开辟一条“内容即货架”的颠覆性赛道。最新数据显示…...

uniapp-商城-29-vuex 关于系统状态的管理

按照我们前面讲的&#xff0c;vuex&#xff0c;的使用方式&#xff1a; 步骤如下&#xff1a; 1 先创建store 文件夹 2 在 store 中 创建一个 index.js 3、 在 store 中&#xff0c;创建一个modules文件夹 4、在store中&#xff0c;创建一个getters.js 5、在modules文件…...

Qt中修改了UI设计文件后编译不生效问题的解决办法

复制工程过来后&#xff1a; 1、删除build文件 2、删除.user文件&#xff0c;恢复为文件最初的那样 3、执行make distclean,删除所有由先前构建过程生成的文件 4、再次打开工程&#xff0c;修改ui文件编译生效&#xff01;...

Python 项目环境配置与 Vanna 安装避坑指南 (PyCharm + venv)

在进行 Python 项目开发时&#xff0c;一个干净、隔离且配置正确的开发环境至关重要。尤其是在使用像 PyCharm 这样的集成开发环境 (IDE) 时&#xff0c;正确理解和配置虚拟环境 (Virtual Environment) 是避免许多常见问题的关键。本文结合之前安装 Vanna 库时遇到的问题&#…...

Matlab FCM模糊聚类

1、内容简介 Matlab 211-FCM模糊聚类 可以交流、咨询、答疑 2、内容说明 略 3、仿真分析 略 4、参考论文 略...

标准的JNI (Java Native Interface) 加载函数 JNI_OnLoad

1.JNI_OnLoad 在 Android Native 开发中&#xff0c;JNI_OnLoad 是动态注册本地方法的标准入口点。以下是一个标准实现示例及其说明&#xff1a; JNI_OnLoad 标准实现 #include <jni.h> #include <string>// 声明本地方法对应的 C/C 函数 jint native_add(JNIEnv…...

微信小程序中使用h5页面预览图片、视频、pdf文件

遇到了这么一个需求&#xff0c;需要在微信小程序中点击文件&#xff0c;进行文件预览。 要求&#xff1a; 图片&#xff1a;长图需要宽度100%高度自适应&#xff1b;横图的话宽度100%&#xff0c;高度居中显示视频&#xff1a;视频不管横向还是竖向都居中显示&#xff0c;有…...

A2A协议详解:打造统一的AI代理通信标准,实现多Agent系统协同

A2A 协议中文说明 文章目录 A2A 解决现有 Agent 问题 Agent 生态系统现状当前面临的主要问题为什么需要统一协议&#xff0c;有个标准采用复用 A2A 解决方案 统一通信标准代理能力发现机制安全协作框架灵活的交互模式 A2A 与 MCP 的关系 MCP 简介两者的区别与联系集成场景协同…...

博客系统案例练习2-用户注册-redis

前言 用户注册 [请求]/user/register[参数]contentType: application/json{"userName":"wangwu","password":"456789","githubUrl": "https://gitee.com/bubble-fish666/spring-cloud","email": &quo…...

【人工智能】推荐开源企业级OCR大模型InternVL3

推荐开源企业级OCR大模型InternVL3 文章参考来源: https://huggingface.co/OpenGVLab/InternVL3-14B-Instruct https://www.aivi.fyi/llms/deploy-InternVL3 InternVL3&#xff0c;这是一个高级多模态大型语言模型 &#xff08;MLLM&#xff09; 系列&#xff0c;展示了卓越的整…...

聊天室项目

一.完善注册页面 1.完善注册页面图标&#xff0c;添加检测注册页面各个登录信息是否完善&#xff0c;并且通过信号和槽与自定义一个计时器&#xff0c;当注册完毕后跳转到显示注册完毕的页面。 2.各个坚持注册页面是否按要求的函数 3.完善主页面&#xff0c;设置信号和槽&…...

并发设计模式实战系列(4):线程池

&#x1f31f; ​大家好&#xff0c;我是摘星&#xff01;​ &#x1f31f; 今天为大家带来的是并发设计模式实战系列&#xff0c;第四章线程池&#xff08;Thread Pool&#xff09;​&#xff0c;废话不多说直接开始~ 目录 一、核心原理深度拆解 1. 线程池核心组件 2. 核心…...

大模型应用案例:主动提问式的 AI 面试官(接入 DeepSeek)

目录 核心逻辑 效果演示 技术选型 大模型应用开发框架&#xff1a;langchain-deepseek UI 展示框架—streamlit 代码获取 后续改进想法 本文附带详细的视频讲解&#xff0c;欢迎小伙伴们来支持—— 【代码宇宙017】大模型&#xff1a;主动提问式的 AI 面试官&#xff0…...

算法笔记—动态规划

1137. 第 N 个泰波那契数 - 力扣&#xff08;LeetCode&#xff09; class Solution { public:int tribonacci(int n) {if(n0) return 0;if(n1||n2) return 1;vector<int> dp(4);//初始化dp[0]0; dp[1]1; dp[2]1;for(int i3;i<n1;i){//滚动数组优化需要循环dp[i%4]dp[…...

Vue3集成Element Plus完整指南:从安装到主题定制上

一、Element Plus简介 Element Plus是一套基于Vue 3.0的桌面端组件库&#xff0c;由饿了么前端团队开源维护。它提供了丰富的UI组件&#xff0c;能够帮助开发者快速构建企业级中后台产品。 1. 安装与卸载 bash 复制 下载 # 安装最新版本 npm install element-plus -S# 卸…...

初识javascript

1. JavaScript 基础语法 (1) 变量声明 JavaScript支持三种声明变量的方式&#xff1a; var&#xff1a;传统的变量声明方式&#xff0c;存在作用域问题&#xff08;函数作用域&#xff09;。 let&#xff1a;块级作用域变量声明方式&#xff0c;避免了var的作用域问题。 co…...

C++项目 —— 基于多设计模式下的同步异步日志系统(5)(单例模式)

C项目 —— 基于多设计模式下的同步&异步日志系统&#xff08;5&#xff09;&#xff08;单例模式&#xff09; 一个问题单例模式实现1. 单例模式&#xff1a;全局唯一实例功能&#xff1a;实现细节&#xff1a;作用&#xff1a; 2. 日志器的注册与查找功能&#xff1a;实现…...

rag搭建,是如何进行向量匹配检索的?

RAG 里为什么要“向量检索”? 在 Retrieval-Augmented Generation (RAG) 中,我们的目标是让 LLM 能够“回答它本身不知道的内容”。做法是: 将知识(文本)进行向量化,存入向量数据库;用户提问后,也将问题向量化;去数据库里 找出与这个问题最相似的一批知识,返回喂给 …...

k8s 基础入门篇之开启 firewalld

前面在部署k8s时&#xff0c;都是直接关闭的防火墙。由于生产环境需要开启防火墙&#xff0c;只能放行一些特定的端口&#xff0c; 简单记录一下过程。 1. firewall 与 iptables 的关系 1.1 防火墙&#xff08;Firewall&#xff09; 定义&#xff1a; 防火墙是网络安全系统&…...

C++在VR/AR图形处理开发中的实战应用

&#x1f9d1; 博主简介&#xff1a;CSDN博客专家、CSDN平台优质创作者&#xff0c;高级开发工程师&#xff0c;数学专业&#xff0c;10年以上C/C, C#, Java等多种编程语言开发经验&#xff0c;拥有高级工程师证书&#xff1b;擅长C/C、C#等开发语言&#xff0c;熟悉Java常用开…...

Matlab 基于模型参考自适应法和SVPWM的异步电机控制

1、内容简介 Matlab 212-基于模型参考自适应法和SVPWM的异步电机控制 可以交流、咨询、答疑 2、内容说明 略 3、仿真分析 略 4、参考论文 略...

深入浅出讲解UDP检验中如何计算检验和

一、计算机中的进制&#xff1a;二进制与十六进制 1. 十进制&#xff08;Decimal&#xff09; 特点&#xff1a;用0-9表示&#xff0c;逢10进1。 例子&#xff1a;数字 123 表示 110221013100110221013100。 2. 二进制&#xff08;Binary&#xff09; 特点&#xff1a;用0和…...

Python类和对象一(十)

封装&#xff1a; 在创建对象之前&#xff0c;通过类将相关的属性和方法打包到一起&#xff0c;然后通过类来生成响应的对象 定义类&#xff1a; 创建对象&#xff1a; 方法里面有个参数self&#xff1a;new的对象 当我们调用类里面方法的时候&#xff0c;py是怎么知道是哪…...

jupyter切换存储路径

一、问题描述 当我采用官网提供的安装方式pip install jupyterlab&#xff0c;在Windows下的powershell里安装jupyterlab成功&#xff0c;并启动&#xff1a;jupyter lab 打开网页&#xff1a;http://localhost:8888/lab 显示如下&#xff1a;成功了&#xff0c;可是我发现这…...

PH热榜 | 2025-04-20

1. Checklist GG 标语&#xff1a;基于人工智能的清单管理工具 介绍&#xff1a;checklist.gg 是一款基于人工智能的检查清单管理工具&#xff0c;旨在帮助组织确保每次都能准确完成任务。 产品网站&#xff1a; 立即访问 Product Hunt&#xff1a; View on Product Hunt 关…...

YOLOv11改进——基于注意力机制和密集小目标增强型EVA模块的设计与实现

随着计算机视觉技术的快速发展&#xff0c;目标检测算法在实时性与检测精度间的平衡成为研究重点。YOLO&#xff08;You Only Look Once&#xff09;系列算法以其高效性和准确性&#xff0c;长期占据实时目标检测领域的前沿位置。然而&#xff0c;尽管最新版本在通用场景表现优…...

n8n 中文系列教程_04.半开放节点深度解析:Code与HTTP Request高阶用法指南

在低代码开发领域&#xff0c;n8n凭借其独特的半开放架构打破了传统自动化工具的边界。本文深度剖析两大核心节点——Code与HTTP Request&#xff0c;从底层原理到企业级实战&#xff0c;揭秘如何通过代码自由扩展与API无缝集成&#xff0c;突破平台限制。无论是对接国产生态&a…...

Linux学习——了解和熟悉Linux系统的远程终端登录

Linux学习——了解和熟悉Linux系统的远程终端登录 一.配置Ubuntu系统的网络和用户 1、设置虚拟机网络为桥接模式 打开VMWare&#xff0c;选择编辑虚拟机设置&#xff0c;在网络适配器设置中&#xff0c;选择“桥接模式”&#xff0c;保存设置并启动Ubuntu。 2、配置Ubuntu的…...

PFLM: Privacy-preserving federated learning with membership proof证明阅读

系列文章目录 提示&#xff1a;这里可以添加系列文章的所有文章的目录&#xff0c;目录需要自己手动添加 例如&#xff1a;第一章 Python 机器学习入门之pandas的使用 提示&#xff1a;写完文章后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目…...

十倍开发效率 - IDEA插件之 Maven Helper

0X00 先看效果 第一个选项表示存在冲突的依赖&#xff0c;可以看到图片中 mysql 的连接依赖发生了冲突&#xff0c;在低版本的上面直接右键选择 Exclude&#xff0c;冲突的依赖就被解决掉了。 0X01 安装 在 Plugins 中直接搜索 Maven Helper&#xff0c;选择第一个进行安装&am…...

线程安全总结

1.线程安全 1.1什么是线程安全 线程安全问题指的是当多个线程同时访问和操作共享资源&#xff08;如变量、数据结构等&#xff09;时&#xff0c;由于缺乏有效的同步控制&#xff0c;导致程序出现不可预期的错误或数据不一致的现象。其核心在于并发操作破坏了程序的正确性。 …...

计算机视觉cv入门之答题卡自动批阅

前边我们已经讲解了使用cv2进行图像预处理与边缘检测等方面的知识&#xff0c;这里我们以答题卡自动批阅这一案例来实操一下。 大致思路 答题卡自动批阅的大致流程可以分为这五步&#xff1a;图像预处理-寻找考试信息区域与涂卡区域-考生信息区域OCR识别-涂卡区域填涂答案判断…...

10.QT-显示类控件|LCD Number|ProgressBar|Calendar Widget(C++)

LCD Number QLCDNumer 是⼀个专⻔⽤来显⽰数字的控件.类似于"⽼式计算器"的效果 属性说明intValueQLCDNumber 显⽰的数字值(int).valueQLCDNumber 显⽰的数字值(double).和intValue是联动的.例如给value设为1.5,intValue的值就是2.另外,设置value和intValue的⽅法名…...

深入探索 Unix 与 Linux:历史、内核及发行版

引言 在当今的计算世界中&#xff0c;Unix 和 Linux 操作系统的影响力无处不在。从驱动互联网的服务器到我们口袋里的智能手机&#xff0c;再到无数嵌入式设备&#xff0c;它们的身影随处可见 1。这两个操作系统家族共享着丰富的历史和相似的设计哲学&#xff0c;但又各自走过…...

HCIP第三次作业

一、实验要求 1&#xff0c;R5为ISP&#xff0c;其上只能配置IP地址;R4作为企业边界路由器&#xff0c; 出口公网地址需要通过PPP协议获取&#xff0c;并进行chap认证 2整个0SPF环境IP基于172.16.0.0/16划分; 3所有设备均可访问R5的环回; 4减少LSA的更新量&#xff0c;加快收敛…...