滴水逆向_引用_友元函数_运算符重载

作业:

运算符号重载实现。

复制代码
struct Person
{
public:
	int x;
	int y;
public:
	Person()
	{
		this->x = 10;
		this->y = 20;
	}
	 Person(int x, int y)
	{
		this->x = x;
		this->y = y;
	}

	//申明友元函数
	 void  Printf(const Person& p)
	 {
		 printf("%d  %d",p.x,p.y);
	}
	//友元函数重载

    Person operator + (const Person& p);
	Person operator - (const Person& p);
	Person operator * (const Person& p);
	Person operator / (const Person& p);
	bool operator >(const Person& p);
	bool operator <(const Person& p);
	bool operator >=(const Person& p);
	bool operator <=(const Person& p);
	bool operator ==(const Person& p);

};


Person Person:: operator + (const Person & p )
{
	this->x =this->x +  p.x;
	this->y = this->y + p.y;

	return *this;
}
Person Person:: operator - (const Person& p)
{
	this->x = this->x - p.x;
	this->y = this->y - p.y;

	return *this;
}
Person Person:: operator * (const Person& p)
{
	this->x = this->x * p.x;
	this->y = this->y * p.y;

	return *this;
}
Person Person:: operator / (const Person& p)
{
	this->x = this->x / p.x;
	this->y = this->y / p.y;
	return *this;
}

bool Person ::operator >(const Person& p)
{
	if (this->x > p.x && this->y > p.y)
	{
		return true;
	}
	return false;
}
bool Person ::operator <(const Person& p)
{
	if (this->x < p.x && this->y< p.y)
	{
		return true;
	}
	return false;
}
bool Person ::operator >=(const Person& p)
{
	if (this->x >= p.x && this->y >= p.y)
	{
		return true;
	}
	return false;
}
bool Person ::operator <=(const Person& p)
{
	if (this->x <= p.x && this->y <= p.y)
	{
		return true;
	}
	return false;
}
bool Person ::operator ==(const Person& p)
{
	if (this->x == p.x && this->y == p.y)
	{
		return true;
	}
	return false;
}

2 引用和指针的区别

复制代码
	x = (int*)10;
00592EB1  mov         dword ptr [x],0Ah

指针修改指向生成的反汇编代码。

引用

复制代码
	x = 10;
00591A01  mov         eax,dword ptr [x]  
00591A04  mov         dword ptr [eax],0Ah  

引用是不可能出现修改指向的反汇编代码的。

这也就是反汇编中唯一能看出来的瑕疵。

相关推荐
small_wh1te_coder4 天前
GCC深度剖析:从编译原理到嵌入式底层实战
汇编·c++·面试·嵌入式·状态模式·c
白书宇5 天前
5.从零开始写LINUX内核--从实模式到保护模式的过渡实现
linux·汇编·数据库·开源
浩浩测试一下5 天前
02高级语言逻辑结构到汇编语言之逻辑结构转换 if (...) {...} else {...} 结构
汇编·数据结构·数据库·redis·安全·网络安全·缓存
蚰蜒螟6 天前
JVM安全点轮询汇编函数解析
汇编·jvm·安全
要记得喝水11 天前
汇编中常用寄存器介绍
开发语言·汇编·windows·c#·.net
技术领导力12 天前
华为开源CANN,再次释放“昇腾转向”信号
汇编
DONG91316 天前
Python 中的可迭代、迭代器与生成器——从协议到实现再到最佳实践
开发语言·汇编·数据结构·python·算法·青少年编程·排序算法
embrace9919 天前
【C语言学习】scanf函数
c语言·开发语言·汇编·学习·青少年编程·c#·编辑器
麦兜*19 天前
【算法】十大排序算法超深度解析,从数学原理到汇编级优化,涵盖 15个核心维度
java·汇编·jvm·算法·spring cloud·ai·排序算法
会掉头发20 天前
x86_64汇编
汇编