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

作业:

运算符号重载实现。

复制代码
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  

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

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

相关推荐
是星辰吖~2 天前
函数战争:内存领地的争夺与撤退
汇编
止观止2 天前
在 WSL2 上从零搭建 ARM 混合编程环境
汇编·arm开发·嵌入式开发·混合编程
say_fall3 天前
8086汇编程序设计_从基础到实战
开发语言·汇编·8086
浩浩测试一下3 天前
LoadPE &&& 原理以及作用 (ASM汇编版本)>>01
汇编·免杀·pe结构·windows编程·二进制逆向·系统loadpe
ThornArmor3 天前
【控制篇】斩断无休止空转:4-bit 指令集里的跳转律令与时序状态机
c语言·汇编·c++·单片机·嵌入式硬件
大阳1234 天前
ARM4.(通过汇编,c语言,固件库点亮LED)
c语言·开发语言·汇编
iCxhust4 天前
8086 汇编 TINY 和 SMALL 编程MODEL区别
汇编·单片机·嵌入式硬件·操作系统·微机原理·8088单板机
say_fall5 天前
从零开始学x86汇编_16位指令系统完全指南
开发语言·汇编·计算机组成·微机原理
txg6666 天前
编译无关的漏洞检测:基于 Transformer 的 LLVM-IR 与汇编鲁棒建模
汇编·深度学习·安全·transformer
浩浩测试一下7 天前
汇编 16位32位64位通用寄存器(逆向分析)
汇编·windows·stm32·单片机·嵌入式硬件·逆向·二进制