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

作业:

运算符号重载实现。

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

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

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

相关推荐
染指11101 天前
35.x64汇编写法(二)
汇编·windows·x64游戏·x64汇编·游戏攻防
Jacen.L2 天前
逆向工程开篇(连载中)
汇编
薛定谔的猫_C8T63 天前
程序人生-Hello’s P2P
c语言·汇编·程序人生·shell·二进制·计算机系统·hello
God_archer3 天前
程序人生-hello’s P2P
linux·c语言·汇编·程序人生
南玖yy3 天前
x86 汇编逻辑运算全解析:从【位操作】到实际应用(AND,OR,NOT,XOR,TEST)
开发语言·汇编·arm开发·后端·架构·策略模式
南玖yy3 天前
深入理解 x86 汇编中的重复前缀:REP、REPZ/REPE、REPNZ/REPNE(进阶详解版)
开发语言·网络·汇编·后端·算法·bochs
Jacen.L3 天前
四、函数调用包含单个参数之Double类型-mmword,movsd,mulsd,addsd指令,总结汇编的数据类型
汇编
网安INF4 天前
深入理解汇编语言中的顺序与分支结构
开发语言·汇编·编程
染指11105 天前
34.x64汇编写法(一)
汇编·x64汇编
廖致君6 天前
打打基础 | 从翻转链表到寄存器、汇编与内存
汇编·数据结构·链表