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

C++——类和对象(中)完结

赋值运算符重载

运算符重载

C++ 为了增强代码的可读性引入了运算符重载 运算符重载是具有特殊函数名的函数 ,也具有其
返回值类型,函数名字以及参数列表,其返回值类型与参数列表与普通的函数类似。
函数名字为:关键字 operator 后面接需要重载的运算符符号
函数原型: 返回值类型  operator 操作符 ( 参数列表 )
注意:
不能通过连接其他符号来创建新的操作符:比如 operator@
重载操作符必须有一个类类型参数
用于内置类型的运算符,其含义不能改变,例如:内置的整型 + ,不 能改变其含义
作为类成员函数重载时,其形参看起来比操作数数目少 1 ,因为成员函数的第一个参数为隐
藏的 this
.* :: sizeof ?: . 注意以上 5 个运算符不能重载。这个经常在笔试选择题中出现。
为了更好理解赋值运算符重载 下面用日期类实现运算符重载

日期类实现运算符重载

operator<运算符的实现

Date.h  Date.cpp test.cpp 三个文件实现

Date.h#include<iostream>using namespace std;class Date
{
public:Date(int year = 1, int month = 1, int day = 1);void Print();bool operator<(const Date& d);private:int _year;int _month;int _day;
};Date.cpp#include"Date.h"Date::Date(int year, int month , int day)
{_year = year;_month = month;_day = day;
}void Date::Print()
{cout << _year << "-" << _month << "-" << _day << endl;
}bool Date::operator<(const Date& d)
{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;}return false;
}test.cpp
#include"Date.h"void Test1()
{Date d1(2023, 11, 2);Date d2(2023, 11, 3);cout << (d1 < d2) << endl;}int main()
{Test1();return 0;
}

因为d1是自定义出来的对象,运算符不能识别自定义类型对象,只能识别内置类型,因此出现了运算符重载 operator+运算符。根据自己需要来定义返回值的不同 比如上面比较大小 返回真假即可 

operator==运算符实现

Date.h
#include<iostream>using namespace std;class Date
{
public:Date(int year = 1, int month = 1, int day = 1);void Print();bool operator<(const Date& d);bool operator==(const Date& d);private:int _year;int _month;int _day;
};Date.cpp
#include"Date.h"Date::Date(int year, int month , int day)
{_year = year;_month = month;_day = day;
}void Date::Print()
{cout << _year << "-" << _month << "-" << _day << endl;
}bool Date::operator<(const Date& d)
{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;}return false;
}bool Date::operator==(const Date& d)
{return _year == d._year&& _month == d._month&& _day == d._day;
}
test.cpp
#include"Date.h"void Test1()
{Date d1(2023, 11, 2);Date d2(2023, 11, 3);cout << (d1 < d2) << endl;cout << (d1 == d2) << endl;
}int main()
{Test1();return 0;
}

 当我们实现完前面两个运算符重载以后,剩余的<= >= != >统统可以复用来实现

operator> >= <= !=运算符实现 

Date.h
#include<iostream>using namespace std;class Date
{
public:Date(int year = 1, int month = 1, int day = 1);void Print();bool operator<(const Date& d);bool operator==(const Date& d);bool operator>(const Date& d);bool operator!=(const Date& d);bool operator<=(const Date& d);bool operator>=(const Date& d);private:int _year;int _month;int _day;
};Date.cpp
#include"Date.h"Date::Date(int year, int month , int day)
{_year = year;_month = month;_day = day;
}void Date::Print()
{cout << _year << "-" << _month << "-" << _day << endl;
}bool Date::operator<(const Date& d)
{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;}return false;
}bool Date::operator==(const Date& d)
{return _year == d._year&& _month == d._month&& _day == d._day;
}bool Date::operator>(const Date& d)
{return !(*this < d);
}
bool Date::operator!=(const Date& d)
{return !(*this == d);
}
bool Date::operator<=(const Date& d)
{return *this < d || *this == d;
}
bool Date::operator>=(const Date& d)
{return !(*this < d) || *this == d;
}test.cpp
#include"Date.h"void Test1()
{Date d1(2023, 11, 2);Date d2(2023, 11, 3);cout << (d1 < d2) << endl;cout << (d1 == d2) << endl;cout << (d1 > d2) << endl;cout << (d1 != d2) << endl;cout << (d1 <= d2) << endl;cout << (d1 >= d2) << endl;
}int main()
{Test1();return 0;
}

因为类成员作为函数成员重载时,第一个默认的形参为隐含的Date*const this指针,因此实现完两个运算符重载函数后,直接复用即可,简洁且高效。

日期类除了比较大小有意思之外 那么日期的相减 相加同样也有意义

那么在计算日期相减 相加 就需要知道某个月 包含的天数 某年是否为闰年

这个时候就需要我们的Getmonthday函数的定义

Getmonthday函数实现

Date.cpp
int Date::Getmonthday(int year, int month)
{assert(year >= 1 && month >= 1 && month <= 12);int arry[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 arry[month];
}

可以完美帮我们判断闰年 和所对应年 月的天数 方便正确计算 日期的相减相加

也不排除有人会在定义对象的时候给了2023 13 29 月和天显然是不合理的 因此我们需要在成员变量在初始化定义(构造函数)的时候 判断下赋的值正不正确

初始化对象后的判断日期类是否正确

Date.cpp
Date::Date(int year, int month , int day)
{_year = year;_month = month;_day = day;if (_year < 1 || _month < 1 || _month>12|| _day < 1 || _day>Getmonthday(_year, _month)){cout << "非法日期" << endl;Print();}
}test.cppvoid Test1()
{Date d1(2023, 11, 2);Date d2(2023, 13, 3);}int main()
{Test1();return 0;
}

operator+=运算符实现

d1+=50

Date.cpp
Date& Date::operator+=(int day)
{_day += day;while (_day > Getmonthday(_year, _month)){_day -= Getmonthday(_year, _month);++_month;if (_month == 13){++_year;_month = 1;}}return *this;
}test.cpp
void Test2()
{Date d1(2023, 11, 2);d1 += 50;d1.Print();}

我们怎么知道最后结果是正确的呢?去网上搜日期计算器就可以了。

 

先进行天数的相加,再判断天数是否大于Getmonthday函数里面月天数的大小,如果大于就先进行当前月天数的相减 然后再++月,再判断月的条件,因为返回类型为Date,出了作用域还在,因此用引用返回。

d1+50也有意义

operator+运算符实现

Date.cpp
Date Date::operator+(int day)
{Date tmp(*this);tmp += day;return tmp;}test.cpp
void Test2()
{Date d1(2023, 11, 2);/*d1 += 50;*/d1.Print();Date ret = d1 + 50;ret.Print();}

直接复用+=即可,因为是d1+50 d1本身不改变 先创建一个临时变量 用拷贝构造传this最初的值,再复用+=加上天数 返回tmp临时变量 因为tmp出了作用域不存在 固不用引用返回。

反观上面+=和+的运算符重载实现,-=和-的实现方法也类似

operator-=运算符实现

Date.cpp
Date& Date::operator-=(int day)
{_day -= day;while (_day <= 0){--_month;if (_month == 0){--_year;_month = 12;}_day += Getmonthday(_year, _month);}return *this;
}test.cpp
void Test2()
{Date d1(2023, 11, 2);/*d1 += 50;*/d1 -= 50;d1.Print();/*d1.Print();Date ret = d1 + 50;ret.Print();*/}

  

operator-运算符实现

Date.cpp
Date Date::operator-(int day)
{Date tmp(*this);tmp -= day;return tmp;
}test.cpp
void Test2()
{Date d1(2023, 11, 2);/*d1 += 50;*//*d1 -= 50;d1.Print();*//*d1.Print();Date ret = d1 + 50;ret.Print();*/Date ret = d1 - 50;d1.Print();ret.Print();}

那么C语言有前置++和后置++ 那么运算符重载自定义对象时怎么分辨呢?

C++之父为了区分前置++和后置++ 在后面++后面加了个int形参

d1++ ++d1 也有意义

operator++(前置)运算符实现

Date.cpp
Date& Date:: operator++()
{*this += 1;return*this;
}test.cpp
void Test2()
{Date d1(2023, 11, 2);/*d1 += 50;*//*d1 -= 50;d1.Print();*//*d1.Print();Date ret = d1 + 50;ret.Print();*//*Date ret = d1 - 50;d1.Print();ret.Print();*/++d1;d1.Print();++d1;d1.Print();}

因为前置++自己本身也会跟着随之改变 所以引用返回this本身。 

operator++(后置)运算符实现

Date.cpp
Date Date::operator++(int)
{Date tmp(*this);*this += 1;return tmp;
}test.cpp
void Test3()
{Date d1(2023, 11, 2);d1.Print();d1++;d1.Print();
}

operator--(前置)运算符实现

Date.cpp
Date& Date::operator--()
{*this -= 1;return *this;
}test.cpp
void Test3()
{Date d1(2023, 11, 2);/*d1.Print();d1++;d1.Print();*/--d1;d1.Print();--d1;d1.Print();
}

operator--(后置)运算符实现 

Date.cpp
Date Date::operator--(int)
{Date tmp(*this);*this -= 1;return tmp;
}test.cpp
void Test3()
{Date d1(2023, 11, 2);/*d1.Print();d1++;d1.Print();*//*--d1;d1.Print();--d1;d1.Print();*/d1.Print();d1--;d1.Print();}

 

既然日期-天数 日期-月 日期++都有意义 那么日期-日期也有意义

比如计算2023到2024年还有多少天

operator-(日期-日期)

Date.cpp
int Date::operator-(const Date& d)
{// 假设左大右小int flag = 1;Date max = *this; //this指向d1Date min = d; //d2// 假设错了,左小右大if (*this < d){max = d;min = *this;flag = -1;}int n = 0;while (min != max){++min;++n;}return n * flag;
}test.cpp
void Test4()
{Date d1(2023, 11, 2);Date d2(2024, 1, 1);cout << (d1 - d2) << endl;
}

但我们在+= 和-=忽略掉了一个问题 就是当给天数 给成负值怎么办?比如d1+=(-50)  d1+(-50)

 当我们用我们上面实现的+=时

d1+=50   d1=d1+(-50)  d1=2-50=-48

void Test4()
{Date d1(2023, 11, 2);//Date d2(2024, 1, 1);d1 += -50;d1.Print();//cout << (d1 - d2) << endl;
}

天数变成了负值 但那个日期计算器人家是能正常计算的

为了能够正确计算负天数,我们只需要加个一个判断条件即可 

 当天数小于0时  d1+=-50 变成了 d1=d1-(-50)      即d1+=50 d1=d1+50;

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)
{if (day < 0){return *this += (-day);}_day -= day;while (_day <= 0){--_month;if (_month == 0){--_year;_month = 12;}_day += Getmonthday(_year, _month);}

日期类实现全部代码

Date.h

#include<iostream>
#include<assert.h>
using namespace std;class Date
{
public:Date(int year = 1, int month = 1, int day = 1);void Print();int Getmonthday(int year, int month);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;Date& operator++();Date operator++(int);Date& operator--();Date operator--(int);int operator-(const Date& d)const;private:int _year;int _month;int _day;
};

Date.cpp


#include"Date.h"Date::Date(int year, int month , int day)
{_year = year;_month = month;_day = day;if (_year < 1 || _month < 1 || _month>12|| _day < 1 || _day>Getmonthday(_year, _month)){cout << "非法日期" << endl;Print();}
}void Date::Print()const
{cout << _year << "_" << _month << "_" << _day << endl;
}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;}return 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 !(*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 !(*this < d) || *this == d;
}
int Date::Getmonthday(int year, int month)
{assert(year >= 1 && month >= 1 && month <= 12);int arry[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 arry[month];
}
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 tmp(*this);tmp += day;return tmp;}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 tmp(*this);tmp -= day;return tmp;
}
Date& Date:: operator++()
{*this += 1;return*this;
}Date Date::operator++(int)
{Date tmp(*this);*this += 1;return tmp;
}Date& Date::operator--()
{*this -= 1;return *this;
}
Date Date::operator--(int)
{Date tmp(*this);*this -= 1;return tmp;
}int Date::operator-(const Date& d)const
{// 假设左大右小int flag = 1;Date max = *this; //this指向d1Date min = d; //d2// 假设错了,左小右大if (*this < d){max = d;min = *this;flag = -1;}int n = 0;while (min != max){++min;++n;}return n * flag;
}

test.cpp

#include"Date.h"//void Test1()
//{
//	/*Date d1(2023, 11, 2);
//	Date d2(2023, 13, 3);*/
//	
//	/*cout << (d1 < d2) << endl;
//	cout << (d1 == d2) << endl;
//	cout << (d1 > d2) << endl;
//	cout << (d1 != d2) << endl;
//	cout << (d1 <= d2) << endl;
//	cout << (d1 >= d2) << endl;*/
//}//void Test2()
//{
//	Date d1(2023, 11, 2);
//	/*d1 += 50;*/
//	/*d1 -= 50;
//	d1.Print();*/
//	/*d1.Print();
//	Date ret = d1 + 50;
//	ret.Print();*/
//	/*Date ret = d1 - 50;
//	d1.Print();
//	ret.Print();*/
//	/*++d1;
//	d1.Print();
//	++d1;
//	d1.Print();*/
//
//}//void Test3()
//{
//	Date d1(2023, 11, 2);
//	/*d1.Print();
//	d1++;
//	d1.Print();*/
//	
//	/*--d1;
//	d1.Print();
//	--d1;
//	d1.Print();*/
//	d1.Print();
//	d1--;
//	d1.Print();
//	
//}
void Test4()
{Date d1(2023, 11, 2);//Date d2(2024, 1, 1);d1 += -50;d1.Print();//cout << (d1 - d2) << endl;
}
int main()
{//Test1();//Test2();//Test3();Test4();return 0;
}

const成员

加上const后为什么不能打印出来呢?因为这里是权限的放大

从const Date*const this变成了 Date*const this 形成了权限的放大

那怎么解决呢?祖师爷决定在括号加上一个const(声明和定义后面都要加上)

当加个const以后 const就修饰了Date*const this变成了const Date*const this  const本质是修饰this

从权限的放大变成了权限的平移 就能打印了 

那么非const对象能调用const函数吗 ?

答案是可以的,因为Date*const this 变成了 const Date*const this 形成了权限的缩小

权限可以平移和缩小 但不能放大。

那么所有函数都能定义成const函数吗?是不可以的,当需要修改成员变量的成员函数,不能改成const。

但能定义成const的成员函数都应该定义成const

这样const对象和非const对象都可以调用(const权限的平移和const权限的缩小)

要修改成员变量的成员函数,不能定义成const

因此在日期类成员函数在不修改成员变量的成员函数后面都可以加上const

取地址及const取地址操作符重载

这两个默认成员函数一般不用重新定义 ,编译器默认会生成。

 当屏蔽掉非const取地址操作函数,非const会去调用const取地址操作函数

这两个取地址操作符重载一般使用编译器默认生成的就可以。

只有特殊情况,才需要重载,比如想让别人获取到指定的内容! 

 不想让别人获取地址可以返回空指针nullptr或者返回自己编造的一个地址。

operator实现<<流插入

为什么不能打印出d1内容,因为<<不识别自定义类型对象 为什么可以识别内置类型呢?

因为C++已经头文件里面的库函数已经帮忙实现了

 为了实现识别自定义类型对象,自己照猫画虎实现一个即可。

Date.h 声明

Date.cpp 定义

但是它有一个问题,就是访问不了私有成员变量,我们暂且先取消掉private,把成员变量放开 

 

但出现了问题 cout<<d1打印不了  d1<<cout可以打印,这又是为什么呢?

 

因为双目操作数的运算符,规定第一个参数必须是左操作数(*this),第二个参数必须是右操作数

d1<<cout 转换  d1.operator<<(&d1,cout);  cout<<d1 第一个参数是cout 第二个是*this所以不行。

那么为了规定传参,流插入的实现只能在全局进行实现,因为成员函数Date对象默认占据第一个位置。

在全局实现又有两个问题,第一个不能访问私有成员变量,第二个不能支持连续插入

 

我们给流插入返回值就能解决连续cout的问题

 

那么访问不了私有成员变量怎么解决呢?这时候就要用到我们的友元函数 

  

友元函数就是在类里面成员函数 前面加个friend 表面是友元函数 我和你是好朋友,可以去你家里玩私有物品,比如游戏机 上厕所等。

那么流提取的实现与流插入相仿

operator实现>>流提取

 流本质是为了解决,自定义类型的输入和输出问题

printf scanf 无法解决自定义类型的输入输出问题面向对象 + 运算符重载解决.

相关文章:

C++——类和对象(中)完结

赋值运算符重载 运算符重载 C 为了增强代码的可读性引入了运算符重载 &#xff0c; 运算符重载是具有特殊函数名的函数 &#xff0c;也具有其 返回值类型&#xff0c;函数名字以及参数列表&#xff0c;其返回值类型与参数列表与普通的函数类似。 函数名字为&#xff1a;关键…...

Sqoop的安装和使用

目录 一.安装 二.导入 1.全量导入 一.MySQL导入HDFS 二.MySQL导入Hive 2.增量导入 一.过滤导入hdfs/hive 二.导出 一.安装 1.下载地址&#xff1a;sqoop下载地址 2.解压 tar -zxvf ./sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz -C ../module/ 3.改名和配置归属权限 #改名…...

java毕业设计基于springboot+vue的村委会管理系统

项目介绍 采用JAVA语言&#xff0c;结合SpringBoot框架与Vue框架以及MYSQL数据库设计并实现的。本村委会管理系统主要包括个人中心、村民管理、村委会管理、村民信息管理、土地变更管理、农业补贴管理、党员信息管理等多个模块。它帮助村委会管理实现了信息化、网络化&#xf…...

【C++】多态 ⑪ ( 纯虚函数和抽象类 | 纯虚函数语法 | 抽象类和实现 | 代码示例 )

文章目录 一、纯虚函数和抽象类1、纯虚函数2、纯虚函数语法3、抽象类和实现 二、完整代码示例 一、纯虚函数和抽象类 1、纯虚函数 纯虚函数 : 在 C 语言中 , " 纯虚函数 " 是 特殊类型的 虚函数 , " 纯虚函数 " 在 父类 中 声明 , 但是没有实现 ; 抽象类 …...

node 第十四天 基于express的第三方中间件multer node后端处理用户上传文件

Multer 是一个 node.js 中间件&#xff0c;用于处理multipart/form-data 类型的表单数据&#xff0c;它主要用于上传文件。它是写在 busboy 之上的所以非常高效。前面我们已经知道了怎样利用express提供的静态资源处理中间件express.static()处理用户请求静态资源文件(图片, js…...

KnowledgeGPT:利用检索和存储访问知识库上增强大型语言模型10.30

利用检索和存储访问知识库上增强大型语言模型 摘要引言2 相关研究3方法3.1 任务定义3.2 知识检索3.2.1 代码实现3.2.2 实体链接3.2.3 获取实体信息3.2.4 查找实体或值3.2.5 查找关系 3.3 知识存储 4 实验4.1 实验设置4.2 流行知识库上的查询4.3 基于知识的问题回答 摘要 大型语…...

Angular material Chips Autocomplete

Chips Autocomplete 官网的例子我没法正常使用&#xff0c;无法实现搜索 我的select是个通用组件&#xff0c;现在贴代码&#xff1a; component.ts import {Component,ElementRef,forwardRef,Input,OnChanges,OnDestroy,OnInit,SimpleChanges,ViewChild, } from angular/co…...

『亚马逊云科技产品测评』活动征文|搭建基础运维环境

授权声明&#xff1a;本篇文章授权活动官方亚马逊云科技文章转发、改写权&#xff0c;包括不限于在 Developer Centre, 知乎&#xff0c;自媒体平台&#xff0c;第三方开发者媒体等亚马逊云科技官方渠道 目录 1、什么是容器化部署 2、连接到控制台 3、安装docker 3.1 更新…...

双指针扫描

import os import sys# 请在此输入您的代码 sinput() Alist(s) nlen(A) t1 for i in range(n//2):if A[i]!A[n-1-i]:t0break if t1:print(Y) else:print(N)n,smap(int,input().split()) alist(map(int,input().split())) #尺取法&#xff0c;变O(n*n)为O(n) #维护一个最短的区间…...

uniapp小程序九宫格抽奖

定义好奖品下标&#xff0c;计时器开始抽奖&#xff0c;请求接口&#xff0c;出现中奖奖品之后&#xff0c;获取中奖商品对应的奖品下标&#xff0c;再次计时器判断当前移动的小标是否为中奖商品的下标&#xff0c;并且是否转到3圈&#xff08;防止转1圈就停止&#xff09;&…...

mysql树状结构查询及注意事项

一、说明 由于Mysql不像oracle一样支持树状查询&#xff0c;需要用户自行处理&#xff0c;本文记录了一种常见的通过自定义函数的方式进行mysql树状查询的方法&#xff0c;以及使用的注意事项。 二、函数 CREATE DEFINERrootlocalhost FUNCTION get_child_menus(in_pid varc…...

TimeGPT-1——第一个时间序列数据领域的大模型他来了

一直有一个问题:时间序列的基础模型能像自然语言处理那样存在吗?一个预先训练了大量时间序列数据的大型模型&#xff0c;是否有可能在未见过的数据上产生准确的预测?最近刚刚发表的一篇论文&#xff0c;Azul Garza和Max Mergenthaler-Canseco提出的TimeGPT-1&#xff0c;将ll…...

通过Google搜索广告传送的携带木马的PyCharm软件版本

导语 最近&#xff0c;一起新的恶意广告活动被发现&#xff0c;利用被入侵的网站通过Google搜索结果推广虚假版本的PyCharm软件。这个活动利用了动态搜索广告&#xff0c;将广告链接指向被黑客篡改的网页&#xff0c;用户点击链接后下载的并不是PyCharm软件&#xff0c;而是多种…...

网站文章收录因素,别人复制文章排名比你原创的好?

我经常看到有站长抱怨“网站不收录”&#xff0c;“排名不好”&#xff0c;“复制的文章为什么秒收”之类的问题。对于SEO从业者来说&#xff0c;这确实是一个打击&#xff0c;认为搜索引擎不公平。凭什么自己原创不收录&#xff0c;别人复制去了&#xff0c;秒收他的&#xff…...

C#开源的一个能利用Windows通知栏背单词的软件 - ToastFish

前言 今天给大家推荐一个C#开源且免费的能利用Windows通知栏背单词的软件&#xff0c;可以让你在上班、上课等恶劣环境下安全隐蔽地背单词&#xff08;利用摸鱼时间背单词的软件&#xff09;&#xff1a;ToastFish。 操作系统要求 目前该软件只支持Windows10及以上系统&…...

速拿offer,超全自动化测试面试题+答案汇总,背完还怕拿不到offer?

目录&#xff1a;导读 前言一、Python编程入门到精通二、接口自动化项目实战三、Web自动化项目实战四、App自动化项目实战五、一线大厂简历六、测试开发DevOps体系七、常用自动化测试工具八、JMeter性能测试九、总结&#xff08;尾部小惊喜&#xff09; 前言 1、你会封装自动化…...

LeetCode----1415. 长度为 n 的开心字符串中字典序第 k 小的字符串

题目 一个 「开心字符串」定义为: 仅包含小写字母 [‘a’, ‘b’, ‘c’].对所有在 1 到 s.length - 1 之间的 i ,满足 s[i] != s[i + 1] (字符串的下标从 1 开始)。比方说,字符串 “abc”,“ac”,“b” 和 “abcbabcbcb” 都是开心字符串,但是 “aa”,“baa” 和 “a…...

2310C++协程超传服务器

原文 告别异步回调模型,写代码更简单.同样也是跨平台,仅头文件的,包含头文件即可用,来看看它的用法. 基本用法 提供getpost服务 coro_http_server server(1, 9001);server.set_http_handler<GET, POST>("/", [](coro_http_request &req, coro_http_respo…...

【排序算法】 计数排序(非比较排序)详解!了解哈希思想!

&#x1f3a5; 屿小夏 &#xff1a; 个人主页 &#x1f525;个人专栏 &#xff1a; 算法—排序篇 &#x1f304; 莫道桑榆晚&#xff0c;为霞尚满天&#xff01; 文章目录 &#x1f4d1;前言&#x1f324;️计数排序的概念☁️什么是计数排序&#xff1f;☁️计数排序思想⭐绝对…...

20231103配置cv180zb的编译环境【填坑篇】

20231103配置cv180zb的编译环境【填坑篇】 2023/11/3 11:36 感谢您选择了晶视科技的cv180zb&#xff0c;让我们一起来填坑。 在你根据文档找不到答案的时候&#xff0c;是不是想把他们家那个写文档的家伙打一顿&#xff0c;我顶你。 当你在在网上找一圈&#xff0c;BAIDU/BING/…...

OpenLayers 可视化之热力图

注&#xff1a;当前使用的是 ol 5.3.0 版本&#xff0c;天地图使用的key请到天地图官网申请&#xff0c;并替换为自己的key 热力图&#xff08;Heatmap&#xff09;又叫热点图&#xff0c;是一种通过特殊高亮显示事物密度分布、变化趋势的数据可视化技术。采用颜色的深浅来显示…...

Appium+python自动化(十六)- ADB命令

简介 Android 调试桥(adb)是多种用途的工具&#xff0c;该工具可以帮助你你管理设备或模拟器 的状态。 adb ( Android Debug Bridge)是一个通用命令行工具&#xff0c;其允许您与模拟器实例或连接的 Android 设备进行通信。它可为各种设备操作提供便利&#xff0c;如安装和调试…...

Spring数据访问模块设计

前面我们已经完成了IoC和web模块的设计&#xff0c;聪明的码友立马就知道了&#xff0c;该到数据访问模块了&#xff0c;要不就这俩玩个6啊&#xff0c;查库势在必行&#xff0c;至此&#xff0c;它来了。 一、核心设计理念 1、痛点在哪 应用离不开数据&#xff08;数据库、No…...

安卓基础(aar)

重新设置java21的环境&#xff0c;临时设置 $env:JAVA_HOME "D:\Android Studio\jbr" 查看当前环境变量 JAVA_HOME 的值 echo $env:JAVA_HOME 构建ARR文件 ./gradlew :private-lib:assembleRelease 目录是这样的&#xff1a; MyApp/ ├── app/ …...

AGain DB和倍数增益的关系

我在设置一款索尼CMOS芯片时&#xff0c;Again增益0db变化为6DB&#xff0c;画面的变化只有2倍DN的增益&#xff0c;比如10变为20。 这与dB和线性增益的关系以及传感器处理流程有关。以下是具体原因分析&#xff1a; 1. dB与线性增益的换算关系 6dB对应的理论线性增益应为&…...

08. C#入门系列【类的基本概念】:开启编程世界的奇妙冒险

C#入门系列【类的基本概念】&#xff1a;开启编程世界的奇妙冒险 嘿&#xff0c;各位编程小白探险家&#xff01;欢迎来到 C# 的奇幻大陆&#xff01;今天咱们要深入探索这片大陆上至关重要的 “建筑”—— 类&#xff01;别害怕&#xff0c;跟着我&#xff0c;保准让你轻松搞…...

【Android】Android 开发 ADB 常用指令

查看当前连接的设备 adb devices 连接设备 adb connect 设备IP 断开已连接的设备 adb disconnect 设备IP 安装应用 adb install 安装包的路径 卸载应用 adb uninstall 应用包名 查看已安装的应用包名 adb shell pm list packages 查看已安装的第三方应用包名 adb shell pm list…...

Web后端基础(基础知识)

BS架构&#xff1a;Browser/Server&#xff0c;浏览器/服务器架构模式。客户端只需要浏览器&#xff0c;应用程序的逻辑和数据都存储在服务端。 优点&#xff1a;维护方便缺点&#xff1a;体验一般 CS架构&#xff1a;Client/Server&#xff0c;客户端/服务器架构模式。需要单独…...

人工智能--安全大模型训练计划:基于Fine-tuning + LLM Agent

安全大模型训练计划&#xff1a;基于Fine-tuning LLM Agent 1. 构建高质量安全数据集 目标&#xff1a;为安全大模型创建高质量、去偏、符合伦理的训练数据集&#xff0c;涵盖安全相关任务&#xff08;如有害内容检测、隐私保护、道德推理等&#xff09;。 1.1 数据收集 描…...

HubSpot推出与ChatGPT的深度集成引发兴奋与担忧

上周三&#xff0c;HubSpot宣布已构建与ChatGPT的深度集成&#xff0c;这一消息在HubSpot用户和营销技术观察者中引发了极大的兴奋&#xff0c;但同时也存在一些关于数据安全的担忧。 许多网络声音声称&#xff0c;这对SaaS应用程序和人工智能而言是一场范式转变。 但向任何技…...