【C++】中类的6个默认成员函数 取地址及const成员函数 学习运算符重载 【实现一个日期类】

文章目录

    • 一、【C++】赋值运算符重载
      • 1.1 运算符重载【引入】
      • 1.2 运算符重载
      • 1.3 赋值运算符重载
      • 1.4 赋值
    • 二、日期类的实现
      • 2.1 判断小于
      • 2.2 判断等于
      • 2.3 判断小于等于
      • 2.4 判断大于
      • 2.5 判断大于等于
      • 2.6 判断不等于
      • 2.7 日期加等天数
      • 2.8 获取月份天数
      • 2.9 日期加天数
      • 2.9.1 日期减等天数
      • 2.9.2 日期减天数
    • 三、前置++ && 后置++
      • 3.1 日期减日期【返回天数】
      • 3.2 流插入
      • 3.3 流提取
      • 3.4 检查输入日期是否合法
    • 四、日期类的实现【源码】
    • 五、const修饰
      • 5.1 const成员函数
      • 5.2 小结一下:
      • 5.3 默认成员函数【取地址及const取地址操作符重载】

一、【C++】赋值运算符重载

1.1 运算符重载【引入】

  • C++为了增强代码的可读性引入了运算符重载,运算符重载是具有特殊函数名的函数,也具有其返回值类型,函数名字以及参数列表,其返回值类型与参数列表与普通的函数类似。
  • 函数名字为:关键字operator后面接需要重载的运算符符号。
  • 函数原型:返回值类型 operator操作符(参数列表)

注意:

  • 不能通过连接其他符号来创建新的操作符:比如operator@

  • 重载操作符必须有一个类类型参数【不能去重载运算符改变内置类型的行为】

  • 用于内置类型的运算符,其含义不能改变,例如:内置的整型+,不 能改变其含义

  • 作为类成员函数重载时,其形参看起来比操作数数目少1个,因为成员函数的第一个参数为隐藏的this

  • .* :: sizeof ?: . 注意以上5个运算符不能重载。这里的是.*,不是*,这写经常在笔试选择题中出现。


  • 我们写了一个日期类,有没有可能要比较比较呢?
class Date
{
public:
	Date(int year = 1900, int month = 1, int day = 1)
	{
		_year = year;
		_month = month;
		_day = day;
	}
	//private: // 一会有解决方法
	int _year;
	int _month;
	int _day;
};

  • 我们写了一个比较相等的函数,如果是传值的话没有必要,我们形参直接写成&,而且也不需要修改,所以再加上const
bool DateEquel(const Date& x, Date& y)
{
	return x._year == y._year
		&& x._month == y._month
		&& x._day == y._day;
}
  • 下面再实现一个函数【比较小于】
bool DateLess(const Date& x, Date& y)
{
	if (x._year < y._year)
	{
		return true;
	}
	else if(x._year == y._year)
	{
		if (x._month < y._month)
		{
			return true;
		}
		else if(x._month == y._month)
		{
			if (x._day < y._day)
			{
				return true;
			}
		}
	}
	return false;
}
  • 上面有一些不好的地方,取名字的问题,取得很乱就不知道这个函数是干什么的

下面我就要用一个新的符号

1.2 运算符重载

  • 这里的运算符重载函数重载的重载不是一个意思
  • 对运算符的行为重新定义

operator+运算符做函数名

  • 刚刚上面写的代码就可以写成下面这样
bool operator==(const Date& x, Date& y)
{
	return x._year == y._year
		&& x._month == y._month
		&& x._day == y._day;
} 
bool operator<(const Date& x, Date& y)
{
	if (x._year < y._year)
	{
		return true;
	}
	else if(x._year == y._year)
	{
		if (x._month < y._month)
		{
			return true;
		}
		else if(x._month == y._month)
		{
			if (x._day < y._day)
			{
				return true;
			}
		}
	}
	return false;
}
  • 就可以这样使用了

在这里插入图片描述

  • 还可以这样做
  • 这里必须要加括号,因为流插入的优先级很高

在这里插入图片描述

  • 注意:参数不能反,左边的操作数对应的是左边

在这里插入图片描述

  • 我们再次回到上面,我们一开始是将内置类型放开的

在这里插入图片描述

  • 如果将他设置成私有,类外面就不能访问了

在这里插入图片描述

  • 我们这里有三种解决方法
  • 第一种就是在类里面搞一个Get函数,这样获取【Java就是这样做的】
class Date
{
public:
	Date(int year = 1900, int month = 1, int day = 1)
	{
		_year = year;
		_month = month;
		_day = day;
	}

	int GetYear()
	{
		return _year;
	}

private:	
	int _year;
	int _month;
	int _day;
};
  • 第二种方法就是将函数放到类里面
class Date
{
public:
	Date(int year = 1900, int month = 1, int day = 1)
	{
		_year = year;
		_month = month;
		_day = day;
	}

	bool operator==(const Date& x, Date& y)
	{
		return x._year == y._year
			&& x._month == y._month
			&& x._day == y._day;
	}

	bool operator<(const Date& x, Date& y)
	{
		if (x._year < y._year)
		{
			return true;
		}
		else if (x._year == y._year)
		{
			if (x._month < y._month)
			{
				return true;
			}
			else if (x._month == y._month)
			{
				if (x._day < y._day)
				{
					return true;
				}
			}
		}
		return false;
	}

private:	
	int _year;
	int _month;
	int _day;
};
  • 然后我们又发现,函数的参数太多了,因为成员函数有一个隐含的this指针

在这里插入图片描述

  • 下面进行修改
class Date
{
public:
	Date(int year = 1900, int month = 1, int day = 1)
	{
		_year = year;
		_month = month;
		_day = day;
	}

	bool operator==(Date& y)
	{
		return _year == y._year
			&& _month == y._month
			&& _day == y._day;
	}

	bool operator<(Date& y)
	{
		if (_year < y._year)
		{
			return true;
		}
		else if (_year == y._year)
		{
			if (_month < y._month)
			{
				return true;
			}
			else if (_month == y._month)
			{
				if (_day < y._day)
				{
					return true;
				}
			}
		}
		return false;
	}

private:	
	int _year;
	int _month;
	int _day;
};
  • 我们使用就可以这样使用了

在这里插入图片描述

  • 我们通过查看反汇编再来了解一下

  • 首先看一下内置类型的比较,是通过指令集的支持

在这里插入图片描述

  • 再来看自定义类型
  • 可以看到两种写法的汇编代码是一样的,编译器会先转化,会一步到位的

在这里插入图片描述

1.3 赋值运算符重载

  • 我们接着写日期类,下面写一个赋值运算符
void operator=(const Date& d)
{
	_year = d._year;
	_month = d._month;
	_day = d._day;
}

在这里插入图片描述

  • 但是我们写的这个又遇到新的问题了,就是连续赋值是无法完成的

在这里插入图片描述

  • 其实连续赋值就是右操作的返回值,做操作的值再进行赋值
  • 返回类型用传引用返回,类型用引用,效率会提高Date&,返回的就是*this,不是this,这是个指针
Date& operator=(const Date& d)
{
	_year = d._year;
	_month = d._month;
	_day = d._day;

	return *this;
}
  • 但是有可能有人这样写代码:d1 = d1
d1 = d1
  • 这里我们就可以加上一个判断,两个相等的话直接返回即可

1.4 赋值

Date& operator=(const Date& d)
{
	if (this != &d)
	{
		_year = d._year;
		_month = d._month;
		_day = d._day;
	}
	return *this;
}

  • 那么我们不写这个赋值,编译器不会不会自动生成一个呢?—>会的!

  • 因为这个是那6个默认成员函数之一

  • 内置类型会值拷贝,自定义类型会调用它的拷贝

在这里插入图片描述

在这里插入图片描述

总结:

  1. 赋值运算符重载格式
  • 参数类型:const T&,传递引用可以提高传参效率
  • 返回值类型:T&,返回引用可以提高返回的效率,有返回值目的是为了支持连续赋值
  • 检测是否自己给自己赋值
  • 返回*this :要复合连续赋值的含义

  1. 赋值运算符只能重载成类的成员函数不能重载成全局函数
  • 赋值运算符重载成全局函数,注意重载成全局函数时没有this指针了,需要给两个参数
Date& operator=(Date& left, const Date& right)
{
	if (&left != &right)
	{
		left._year = right._year;
		left._month = right._month;
		left._day = right._day;
	}
	return left;
}

原因:赋值运算符如果不显式实现,编译器会生成一个默认的。此时用户再在类外自己实现一个全局的赋值运算符重载,就和编译器在类中生成的默认赋值运算符重载冲突了,故赋值运算符重载只能是类的成员函数。

在这里插入图片描述

二、日期类的实现

  • 前面实现了一些逻辑,接下来我们就实现剩下的
  • 所有代码在最后~~

2.1 判断小于

  • 在上面已经说明了,这里就直接写出来了
bool operator<(const Date& d)
{
	if (_year < d._year)
	{
		return true;
	}
	else if (_year == d._year)
	{
		if (_month < d._month)
		{
			return true;
		}
		else if (_month == d._month)
		{
			if (_day < d._day)
			{
				return true;
			}
		}
	}
	return false;
}

2.2 判断等于

  • 直接判断相不相等
bool operator==(const Date& d)
{
	return _year == d._year
		&& _month == d._month
		&& _day == d._day;
}

2.3 判断小于等于

  • 上面实现了小于,下面我们来实现一下小于等于
  • 既然上面都写了小于和等于了,我们这里就可以直接复用
bool operator<=(const Date& d)
{
	return *this <= d || *this == d;
}

2.4 判断大于

  • 这里的大于不就是小于等于的取反
bool operator>(const Date& d)
{
	return !(*this <= d);
}

2.5 判断大于等于

  • 大于等于就是小于取反
bool operator>=(const Date& d)
{
	return !(*this < d);
}

2.6 判断不等于

  • 不等于就是等于的取反
bool operator!=(const Date& d)
{
	return !(*this == d);
}

2.7 日期加等天数

2.8 获取月份天数

  • 在实现日期加天数的时候我们需要再先实现一个获取月份天数
  • 因为这里的获取月份天数需要被频繁调用,我们这里使用inline,可以不写【在类内声明同时定义的成员函数自动转化为内联函数】
  • 我们还将数组使用static修饰,避免了频繁开辟
  • 然后再判断闰年的时候我们把判断月份放到了前面,首先判断月份是否为2,为真继续判断下面的,否则每次都要执行那么一长串的判断闰年
inline int GetMonthDay(int year,int month)
{
	assert(month < 13 && month > 0);
	// 放到静态区
	static int MonthDays[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	// 先判断月份
	if (month == 2 && (((year % 100 == 0) && (year % 4 == 0)) || (year % 400 != 0)))
		return 29;
	return MonthDays[month];
}
  • 然后继续来实现
  • 首先加上天数,然后判断当前月的天数和加上的天数
  • 然后进行减掉天数,月份+1,如果月份等于了13,年就+1,月份赋值为1
Date& operator+=(int day)
{
	// 这里就直接修改了
	_day += day;
	while (_day > GetMonthDay(_year, _month))
	{
		_day -= GetMonthDay(_year, _month);
		++_month;
		if (_month == 13)
		{
			++_year;
			_month = 1;
		}
	}
	return *this;
}

2.9 日期加天数

  • 上面是实现了+=,+也就很好实现了,这里只需要另外开一块空间,修改别的空间就不会影响我这里的值
  • 这里不可以用引用返回,tmp是一个临时对象,必须用传值返回
Date operator+(int day)
{
	Date tmp(*this);
	tmp._day += day;
	while (tmp._day > GetMonthDay(tmp._year, tmp._month))
	{
		tmp._day -= GetMonthDay(tmp._year, tmp._month);
		++tmp._month;
		if (tmp._month == 13)
		{
			++tmp._year;
			tmp._month = 1;
		}
	}
	return tmp;
}
  • 上面那个+和+=的代码相似,我们也可以复用一下
Date operator+(int day)
{
	Date tmp(*this);
	tmp += day;
	return tmp;
}

  • 上面的代码是+复用+=,那么我们也可以用+=复用+
Date& operator+=(int day)
{
	*this = *this + day;
	return *this;
}

  • 那么这两种写法哪一种比较好呢?

在这里插入图片描述

  • 这里左边的更好,右边的会复用+,而+里面会创建临时对象

在这里插入图片描述

2.9.1 日期减等天数

  • 经过上面的思考,我们先实现减等
Date& operator-=(int day)
{
	_day -= day;
	while (_day <= 0)
	{
		--_month;
		if (_month == 0)
		{
			--_year;
			_month = 12;
		}
		_day += GetMonthDay(_year, _month);
	}
	return *this;
}

2.9.2 日期减天数

Date operator-(int day)
{
	Date tmp = *this;
	tmp -= day;

	return tmp;
}

三、前置++ && 后置++

  • 前置++很简单
Date& operator++()
{
	*this += 1;
	return *this;
}
  • 后置++要返回++后的值【这里要注意,后置++的操作符是有一个**(int)区分的**】
  • 后置++相比前置++的效率是低一些的
Date operator++(int)
{
	Date tmp = *this;
	*this += 1;
	return tmp;
}

3.1 日期减日期【返回天数】

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

3.2 流插入

  • 对于内置类型可以流插入,那么内置类型也可以流插入

  • 对于流插入【cout】,对于库里面全局的ostream类型的对象 -->点我

在这里插入图片描述

  • 这里我们在使用的时候就反了,第一个被this占用了
void operator<<(ostream& out)
{
	out << _year << "年" << _month << "月" << _day << "日" << endl;
}
  • 作为成员函数重载,this指针占据第一个参数,Date必须是在操作数

在这里插入图片描述

  • 所以我们就必须让ostream占据第一个位置

  • 想要占据第一个参数,就不能写成成员函数,就要写成全局函数

  • 当我们写成全局函数的时候,·不能访问类的私有了,这里也要后面的友元

void operator<<(ostream& out, const Date& d)
{
	out << d._year << "年" << d._month << "月" << d._day << "日" << endl;
}
  • 这里想要改成多个插入,我们返回值就要改一下
ostream& operator<<(ostream& out, const Date& d)
{
	out << d._year << "年" << d._month << "月" << d._day << "日" << endl;
	return out;
}

在这里插入图片描述

3.3 流提取

  • 流提取是cin

在这里插入图片描述

  • 这里就不能使用const了
istream& operator>>(istream& in, Date& d)
{
	cout << "请依次输入年月日:>";
	in >> d._year >> d._month >> d._day;
	return in;
}

在这里插入图片描述

3.4 检查输入日期是否合法

bool CheckInvalid()
{
	if (_year <= 0
		|| _month < 1
		|| _month > 12
		|| _day < 1
		|| _day > GetMonthDay(_year,_month))
	{
		return false;
	}
	else
	{
		return true;
	}
}
  • 这个时候把可以改检查的地方就检查一下

四、日期类的实现【源码】

#include <iostream>
#include <assert.h>
using namespace std;

class Date
{
public:
	// 构造函数
	Date(int year = 1900, int month = 1, int day = 1)
	{
		_year = year;
		_month = month;
		_day = day;

		if (!CheckInvalid())
		{
			cout << "构造日期非法" << endl;
		}
	}
	// 判断等于
	bool operator==(const Date& d)
	{
		return _year == d._year
			&& _month == d._month
			&& _day == d._day;
	}
	// 判断小于
	bool operator<(const Date& d)
	{
		if (_year < d._year)
		{
			return true;
		}
		else if (_year == d._year)
		{
			if (_month < d._month)
			{
				return true;
			}
			else if (_month == d._month)
			{
				if (_day < d._day)
				{
					return true;
				}
			}
		}
		return false;
	}
	// 判断小于等于
	bool operator<=(const Date& d)
	{
		return *this <= d || *this == d;
	}
	// 判断大于
	bool operator>(const Date& d)
	{
		return !(*this <= d);
	}
	// 判断大于等于
	bool operator>=(const Date& d)
	{
		return !(*this < d);
	}
	// 判断不等于
	bool operator!=(const Date& d)
	{
		return !(*this == d);
	}
	// 日期加等天数

	Date& operator+=(int day)
	{
		_day += day;
		while (_day > GetMonthDay(_year, _month))
		{
			_day -= GetMonthDay(_year, _month);
			++_month;
			if (_month == 13)
			{
				++_year;
				_month = 1;
			}
		}
		return *this;
	}

	Date operator+(int day)
	{
		Date tmp(*this);
		//Date tmp = *this;
		tmp += day;
		return tmp;
	}

	// 日期加天数
	Date operator+(const Date& d)
	{
		Date tmp(*this);
		tmp._day += d._day;
		while (d._day > GetMonthDay(tmp._year, tmp._month))
		{
			tmp._day -= GetMonthDay(tmp._year, tmp._month);
			++tmp._month;
			if (tmp._month == 13)
			{
				++tmp._year;
				tmp._month = 1;
			}
		}
		return tmp;
	}

	// 日期-=天数
	Date& operator-=(int day)
	{
		_day -= day;
		while (_day <= 0)
		{
			--_month;
			if (_month == 0)
			{
				--_year;
				_month = 12;
			}
			_day += GetMonthDay(_year, _month);
		}
		return *this;
	}

	// 日期减天数
	Date operator-(int day)
	{
		Date tmp = *this;
		tmp -= day;

		return tmp;
	}

	// 前置++
	Date& operator++()
	{
		*this += 1;
		return *this;
	}

	// 后置++
	Date operator++(int)
	{
		Date tmp = *this;
		*this += 1;

		return tmp;
	}

	// 日期-日期
	int operator-(const Date& d)
	{
		int flag = 1;
		Date max = *this;
		Date min = d;

		if (*this < d)
		{
			int flag = -1;
			max = d;
			min = *this;
		}

		int n = 0;
		while (min != max)
		{
			++min;
			++n;
		}
		return n * flag;
	}


	// 获取月份天数[可以不写inline,类里默认就是]
	inline int GetMonthDay(int year, int month)
	{
		assert(month < 13 && month > 0);
		// 放到静态区
		static int MonthDays[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
		// 先判断月份
		if (month == 2 && (((year % 100 == 0) && (year % 4 == 0)) || (year % 400 != 0)))
			return 29;
		return MonthDays[month];
	}

	// 拷贝构造
	Date& operator=(const Date& d)
	{
		if (this != &d)
		{
			_year = d._year;
			_month = d._month;
			_day = d._day;
		}
		return *this;
	}
	friend ostream& operator<<(ostream& out, const Date& d);
	friend istream& operator>>(istream& in, Date& d);

	bool CheckInvalid()
	{
		if (_year <= 0
			|| _month < 1
			|| _month > 12
			|| _day < 1
			|| _day > GetMonthDay(_year,_month))
		{
			return false;
		}
		else
		{
			return true;
		}
	}

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

ostream& operator<<(ostream& out, const Date& d)
{
	out << d._year << "年" << d._month << "月" << d._day << "日" << endl;
	return out;
}

istream& operator>>(istream& in, Date& d)
{
	while (1)
	{
		cout << "请依次输入年月日:>";
		in >> d._year >> d._month >> d._day;

		if (!d.CheckInvalid())
		{
			cout << "输入非法日期,请重新输入" << endl;
		}
		else
		{
			break;
		}
	}
	return in;
}

五、const修饰

5.1 const成员函数

  • 将const修饰的“成员函数”称之为const成员函数,const修饰类成员函数,实际修饰该成员函数隐含的this指针,表明在该成员函数中不能对类的任何成员进行修改。

在这里插入图片描述

  • 我们看下面这段代码
class Date
{
public:
	Date(int year, int month, int day)
	{
		_year = year;
		_month = month;
		_day = day;
	}
	void Print()
	{
		cout << "Print()" << endl;
		cout << "year:" << _year << endl;
		cout << "month:" << _month << endl;
		cout << "day:" << _day << endl << endl;
	}
	void Print()
	{
		cout << "Print()const" << endl;
		cout << "year:" << _year << endl;
		cout << "month:" << _month << endl;
		cout << "day:" << _day << endl << endl;
	}
private:
	int _year; // 年
	int _month; // 月
	int _day; // 日
};
  • 这里会出现一个权限放大的问题

在这里插入图片描述

  • 那么在参数就需要改成const Date*

  • 为了解决这个问题,我们就要在函数后面的位置加上一个const

  • 修饰的是this指针指向的内容

在这里插入图片描述

  • 那么不是下面方法调用也是可以的,因为这个是权限的缩小

在这里插入图片描述

  • const对象可以调用,非const对象也可以调用

  • 那么全部函数都可以加上const吗?—>不可以!
  • 如果函数内部要被修改,那肯定是不能加的
  • 上面写的日期类的部分函数也可以加上~~

5.2 小结一下:

  • 成员函数如果是一个对成员变量只进行访问的函数,建议加上const,这样const对象和非const对象都可以访问

  • 成员函数如果是一个对成员变量进行读写访问的函数,不可以加上const,否则不能修改成员变量

  1. const对象可以调用非const成员函数吗? --> 不可以!【权限放大】
  2. 非const对象可以调用const成员函数吗?–> 可以!【权限缩小】
  3. const成员函数内可以调用其它的非const成员函数吗?–> 不可以!【权限放大】
  4. 非const成员函数内可以调用其它的const成员函数吗?–> 可以!【权限缩小】

5.3 默认成员函数【取地址及const取地址操作符重载】

  • 前面章节学习了4个默认成员函数了,剩下两个再看一下

在这里插入图片描述

  • 这两个默认成员函数一般不用重新定义 ,编译器默认会生成。
class Date
{
public:
	Date* operator&()
	{
		return this;
	}
	const Date* operator&()const
	{
		return this;
	}
private:
	int _year; // 年
	int _month; // 月
	int _day; // 日
};
  • 比如说不想让别人拿到我的地址,普通对象返回空,const对象返回假地址
  • 就可以这样写:
Date* operator&()
{
	return nullptr;
}
const Date* operator&()const
{
	int i = 0;
	return (const A*)&i;
}
  • 这两个运算符一般不需要重载,使用编译器生成的默认取地址的重载即可,只有特殊情况,才需要重载,比如想让别人获取到指定的内容!

最后本文主要学习了运算符重载这个知识点,并且在学习的时候实现了一个日期类,望烙铁们学有所成~~

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/395120.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

LeetCode 0590. N 叉树的后序遍历:深度优先搜索(DFS)

【LetMeFly】590.N 叉树的后序遍历&#xff1a;深度优先搜索(DFS) 力扣题目链接&#xff1a;https://leetcode.cn/problems/n-ary-tree-postorder-traversal/ 给定一个 n 叉树的根节点 root &#xff0c;返回 其节点值的 后序遍历 。 n 叉树 在输入中按层序遍历进行序列化表…

C语言字符串函数strtok

注意&#xff1a; 该函数会将改变原始字符串 str&#xff0c;使其所包含的所有分隔符变成结束标记 ‘\0’ 。由于该函数需要更改字符串 str&#xff0c;因此 str 指向的内存必须是可写的。首次调用时 str 指向原始字符串&#xff0c;此后每次调用 str 用 NULL 代替。示例&#…

Ubuntu本地安装code-server结合内网穿透实现安卓平板远程写代码

文章目录 1.ubuntu本地安装code-server2. 安装cpolar内网穿透3. 创建隧道映射本地端口4. 安卓平板测试访问5.固定域名公网地址6.结语 1.ubuntu本地安装code-server 准备一台虚拟机,Ubuntu或者centos都可以&#xff0c;这里以VMwhere ubuntu系统为例 下载code server服务,浏览器…

Leetcode 283.移动零

给定一个数组 nums&#xff0c;编写一个函数将所有 0 移动到数组的末尾&#xff0c;同时保持非零元素的相对顺序。 请注意 &#xff0c;必须在不复制数组的情况下原地对数组进行操作。 示例 1: 输入: nums [0,1,0,3,12] 输出: [1,3,12,0,0]示例 2: 输入: nums [0] 输出: […

来了解AI自动直播带货新玩法!普通人也能轻松上手!

抖捧AI实景自动直播系统&#xff0c;以低成本常态化高效率的直播方式&#xff0c;为进入直播间的用户打造了更真实的体验&#xff0c;更帮助了大量的实体商家降低自播的成本&#xff0c;实现降本增效&#xff0c;接下来看看抖捧最新的餐饮休娱案例及玩法&#xff0c;每天直播八…

实用工具推荐

可以提高你工作效率的工具 SnipasteSnipaste Snipaste Snipaste

数字化商品管理:革新鞋服零售模式,引领智能商业新时代

随着科技的快速发展&#xff0c;数字化浪潮席卷各行各业&#xff0c;鞋服零售企业亦不例外。在这个新时代&#xff0c;数字化商品管理不仅成为鞋服零售企业革新的关键&#xff0c;更是其引领智能商业浪潮的重要引擎。本文将围绕数字化商品管理如何深刻影响鞋服零售模式&#xf…

HashCat报错

HashCat执行命令 hashcat -a 3 -m 17225 -2 ?l?u $pkzip2$3*1*1*0*0*24*143c*4917*4bfe891c40b54ed8a613dc05c1a5a5c6df68da07f2a00e55d705a5bc04f3c149a53ab891*1*0*8*24*2e57*490e*028de43f9edfed13437c0964625b78391e2876248d3362b240c2bbfd7dbc3ff022ef2e07*2*0*67*5b*d6…

建立流行病预警指数体系并优化传染病模型:对公共卫生突发事件监测数据的分析

应对紧急情况造成的损害的能力是紧急能力现代化的重要象征。 在应对紧急情况时&#xff0c;政府机构和决策者需要更多信息来源&#xff0c;以更有效地估计灾难可能的演变。 这篇论文提出了一个预测COVID-19动态演变的优化模型&#xff0c;该模型将系统动力学的传播算法与预警指…

css pointer-events 多层鼠标点击事件

threejs 无法滑动视角&#xff0c;菜单界面覆盖threejs操作事件。 pointer-events /* Keyword values */ pointer-events: auto; pointer-events: none; pointer-events: visiblePainted; /* SVG only */ pointer-events: visibleFill; /* SVG only */ pointer-events: visib…

【vue+leaflet】vue项目中使用leaflet绘制室内平面图、leaflet.pm在平面图中绘制点、线、面图层(一)

效果图: 一,插件安装 npm i leaflet --save // 我的版本^1.9.4 npm i leaflet.pm --save // 我的版本^2.2.0附官网链接: leaflet官网: https://leafletjs.com/index.html leaflet.pm官网: https://www.npmjs.com/package/leaflet.pm?activeTabreadme 二,模块引入 因为我…

OLMo论文里的模型结构的小白解析

模型参数量 以7B为例&#xff0c;隐藏层为4086&#xff0c;attention heads为32 训练的token量为2.46T 训练策略 超参数 在我们的硬件上优化训练吞吐量&#xff0c;同时最小化损失峰值和缓慢发散的风险来选择超参数 损失峰值&#xff1a;在机器学习中&#xff0c;"损失峰…

lazada、速卖通卖家如何掌握自养号测评技巧打造高评价产品?

做跨境电商卖家都知道&#xff0c;国外的买家购物比较理性&#xff0c;也喜欢货比三家&#xff0c;所以店铺想要留住客户&#xff0c;就需要一些优质的产品来吸引他们。产品评价是卖家获取买家信任的重要途径&#xff0c;评价越高的产品&#xff0c;销量也就越好。 尤其是 Shop…

猫多喝水好吗?可以促进猫咪多喝水的主食分享

猫咪多喝水确实是有益的。适量的饮水对于猫咪的健康至关重要&#xff0c;有助于维持体液平衡、促进消化、减少便秘的风险&#xff0c;并对泌尿系统的健康起到保护作用。正常情况下&#xff0c;建议每公斤体重的猫每天摄入60-80毫升的水&#xff0c;除了与体重相关外&#xff0c…

RabbitMQ消息可靠性投递与ACK确认机制

1.RabbitMQ的消息可靠性投递 什么是消息的可靠性投递 保证消息百分百发送到消息队列中去保证MQ节点成功接收消息消息发送端需要接收到MQ服务端接收到消息的确认应答完善的消息补偿机制&#xff0c;发送失败的消息可以再感知并二次处理 RabbitMQ消息投递路径 生产者–>交换机…

碳化硅模块使用烧结银双面散热DSC封装的优势与实现方法

碳化硅模块使用烧结银双面散热DSC封装的优势与实现方法 新能源车的大多数最先进 (SOTA) 电动汽车的牵引逆变器体积功率密度范围从基于 SSC-IGBT 的逆变器的 <10 kW/L 到基于 SSC-SiC 的逆变器的约 25 kW/L。100 kW/L 代表了这一关键指标的巨大飞跃。 当然&#xff0c;随着新…

GaiaDB-X 获选北京国家金融科技认证中心「数据领域首批专项示范与先行单位」

2023 年 12 月 21 日至 22 日&#xff0c;「2023北京国际金融安全论坛暨金融科技标准认证生态大会」在北京金融安全产业园举办。百度智能云分布式数据库 GaiaDB-X 产品荣登「数据领域首批专项示范与先行单位」名单&#xff0c;并获得了由北京国家金融科技认证中心颁发的「数据产…

Sora背后的论文(1):使用 lstms 对视频展现进行无监督学习

之前那篇《Sora背后的32篇论文》发出后&#xff0c;大家都觉得不错&#xff0c;有很多小伙伴都开始啃论文了。 那么我就趁热打铁&#xff0c;把这32篇论文的通俗解读版贴一下。 从去年开始&#xff0c;我基本上形成了一个思维方式&#xff0c;任何事情做之前先看看 有没有好的…

Vue3+vite搭建基础架构(9)--- 使用vite-plugin-svg-icons

Vue3vite搭建基础架构&#xff08;9&#xff09;--- 使用vite-plugin-svg-icons 说明安装vite-plugin-svg-icons使用vite-plugin-svg-icons添加svg-icon组件和全局组件js文件 测试svg雪碧图 说明 这里记录下自己在Vue3vite的项目使用vite-plugin-svg-icons来全局使用svg雪碧图…

算法沉淀——多源 BFS(leetcode真题剖析)

算法沉淀——多源 BFS&#xff08;leetcode真题剖析&#xff09; 01.矩阵02.飞地的数量03.地图中的最高点04.地图分析 多源 BFS 是指从多个源点同时进行广度优先搜索的算法。在传统的 BFS 中&#xff0c;我们通常从一个起始点开始&#xff0c;逐层遍历所有的相邻节点。而在多…
最新文章