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

embedded/2025/2/26 16:42:47/

作业:

运算符号重载实现。

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  

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

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


http://www.ppmy.cn/embedded/167301.html

相关文章

工具方法 - 合规性矩阵

Compliance matrix &#xff08;合规性矩阵&#xff09;是产品需求管理中的一个重要工具&#xff0c;它是用来识别、跟踪、监控和组织所有客户和利益相关方需求是否被满足的工具。具体来说&#xff0c;Compliance matrix需要用一行一行的证据来证明被设计的产品针对每个需求的实…

std::thread的同步机制

在 C 中&#xff0c;std::thread 用于创建和管理线程。为了确保多个线程能正确、安全地访问共享资源&#xff0c;避免数据竞争和不一致问题&#xff0c;需要使用同步机制。 互斥锁&#xff08;std::mutex&#xff09; 原理&#xff1a;互斥锁是一种最基本的同步原语&#xff…

跟着李沐老师学习深度学习(十六)

继续学习深度学习&#xff08;十六&#xff09; 继续理解transformer 对于transformer的理解感觉还是云里雾里的&#xff0c;今天又找了一些视频进行一个梳理。 一个浅解 在B站学习发现评论区真的很不错&#xff0c;在沐神讲transformer论文的评论下&#xff0c;有一个评论…

AR技术下的电商:虚拟试穿/试用/试戴成新风尚

随着科技的日新月异&#xff0c;增强现实&#xff08;AR&#xff09;技术正悄然改变着我们的生活&#xff0c;尤其在电子商务领域&#xff0c;AR技术的融入正掀起一场前所未有的变革。那么&#xff0c;AR技术究竟是何方神圣&#xff1f;它在电商领域又展现出了哪些非凡的应用呢…

QSplashScreen --软件启动前的交互

目录 QSplashScreen 类介绍 使用方式 项目中使用 THPrinterSplashScreen头文件 THPrinterSplashScreen实现代码 使用代码 使用效果 QSplashScreen 类介绍 QSplashScreen 是 Qt 中的一个类&#xff0c;用于显示启动画面。它通常在应用程序启动时显示&#xff0c;以向用户显…

MySQL存储过程详解

以下是关于 MySQL 存储过程的详细教程&#xff0c;包含基本概念、语法、示例及注意事项&#xff1a; MySQL 存储过程教程 1. 存储过程是什么&#xff1f; 定义&#xff1a;存储过程&#xff08;Stored Procedure&#xff09;是一组预先编译并存储在数据库中的 SQL 语句集合&a…

eclogy后台运维笔记(写的很乱,只限个人观看)

组织权限&#xff1a; 矩阵管理 这个很重要&#xff0c;比如进行流程操作者的选择时&#xff0c;我们进行需要选择财务部的出纳&#xff0c;会计&#xff0c;总经理。我们不能去直接选定一个人&#xff0c;万一这个人离职了&#xff0c;那所有的流程都要手动修改&#xff0c;…

selenium如何实现,开启浏览器的开发者工具模式,并且开启 toggle移动设备模拟模式

核心实现代码 pythonCopy Code from selenium import webdriver from selenium.webdriver.chrome.options import Options def enable_devtools_with_toggle(): options Options() # 强制开启开发者工具 options.add_argument("--auto-open-devtools-for-tabs&quo…