当前位置: 首页 > news >正文

php网站如何攻击设计手机网站页面尺寸

php网站如何攻击,设计手机网站页面尺寸,wordpress led主题,wordpress 运费模板基础 运算符重载#xff0c;就是对已有的运算符重新进行定义#xff0c;赋予其另一种功能#xff0c;以适应不同的数据类型。 运算符重载也可以发生函数重载。 语法#xff1a; void operator(); //代表了被重载的运算符。函数的参数个数取决于两个因素。1)运算符是一元(一…基础 运算符重载就是对已有的运算符重新进行定义赋予其另一种功能以适应不同的数据类型。 运算符重载也可以发生函数重载。 语法 void operator(); //代表了被重载的运算符。函数的参数个数取决于两个因素。1)运算符是一元(一个参数)的还是二元(两个参数)2)运算符被定义为全局函数(对于一元是一个参数对于二元是两个参数)还是成员函数(对于一元没有参数对于二元是一个参数-此时该类的对象用作左耳参数) 成员函数重载 全局函数重载 原理 运算符重载(operator overloading)只是一种”语法上的方便”,也就是它只是另一种函数调用的方式。 是否可重载 几乎C中所有的运算符都可以重载但运算符重载的使用时相当受限制的。 不能改变运算符优先级不能改变运算符的参数个数。 加号运算符重载 //利用成员函数实现加号运算符重载 Person operator(Person p) {Person temp;temp.m_A this-m_A p.m_A;temp.m_B this-m_B p.m_B;return temp; }private:int m_A;int m_B;//利用全局函数实现加号运算符重载 Person operator(Person p1, Person p2) {Person temp;temp.m_A p1.m_A p2.m_A;temp.m_B p1.m_B p2.m_B;return temp; }重载左移操作符(),使得 cout 可以输出自定义对象 为什么不用 成员函数重载 实现 使用 全局函数 重载 运算符无法链式编程 cout 是 ostream 类的对象全局只有一个所以使用 。 要实现 cout 链式输出需返回 cout 引用 如果要访问类中私有属性配合友元实现 //重载 运算符案列 class Person{friend ostream operator(ostream os, Person person);//友元 public:Person(int id,int age){mID id;mAge age;} private:int mID;int mAge; };//重载 运算符 ostream operator(ostream os, Person person){os ID: person.mID Age: person.mAge;return os; }int main(){Person person(1001, 30);//cout person; //cout.operator(person)cout person | endl;return EXIT_SUCCESS; } 自增自减(/–)运算符重载 class Complex{public:Complex(){mA 0;mB 0;}//重载前置Complex operator(){mA;mB;return *this; //返回的的是引用可以实现链式编程b}//重载后置Complex operator(int){ Complex temp;temp.mA this-mA;temp.mB this-mB;mA;mB;return temp; //temp是局部对象不能返回引用所以不能实现链式编程。}//前置--Complex operator--(){mA--;mB--;return *this;}//后置--Complex operator--(int){Complex temp;temp.mA mA;temp.mB mB;mA--;mB--;return temp;}private:int mA;int mB; };如何区分重载的前置还是后置通过占位参数来区分有 int 的为后置- - 同理。 要优先使用前缀形式由于前缀形式少创建了一个临时对象效率经常会略高一些。 指针运算符( *、- )重载 利用智能指针管理 new 出来的 Person 的释放操作。 //被维护的类 class Person{ public:Person(int param){this-mParam param;}void PrintPerson(){cout Param: mParam endl;} private:int mParam; };//智能指针 class SmartPointer{ public:SmartPointer(Person* person){this-pPerson person;}//重载指针的 - 操作符Person* operator-(){return pPerson;}//重载指针的 * 操作符Person operator*(){return *pPerson;}~SmartPointer(){if (pPerson ! NULL){delete pPerson; //在析构中释放 被维护对象空间this.pPerson NULL;}} public:Person* pPerson; //维护一个被管理类的指针 };void test01(){SmartPointer pointer(new Person(18)); //通过构造实例化被被维护的对象//本质pointer--PrintPerson(); 编译器简化为pointer-PrintPerson();pointer-PrintPerson(); (*pointer).PrintPerson(); } 智能指针类 执行在栈上执行完后自动释放同时也释放了被维护对象的空间。 自动释放体现出智能 指针运算符( * - )重载体现出 指针 赋值()运算符重载 编译器 默认给一个类提供四个函数默认构造拷贝构造浅拷贝析构函数 operator 浅拷贝。 //赋值()运算符重载-------详细案列 class Person{friend ostream operator(ostream os,const Person person){os ID: person.mID Age: person.mAge endl;return os;} public:Person(int id,int age){this-mID id;this-mAge age;}//重载赋值运算符Person operator(const Person person){this-mID person.mID;this-mAge person.mAge;return *this;} private:int mID;int mAge; };//1. 号混淆的地方 void test01(){Person person1(10, 20);Person person2 person1; //调用拷贝构造//如果一个对象还没有被创建则必须初始化也就是调用构造函数//上述例子由于person2还没有初始化所以会调用构造函数//由于person2是从已有的person1来创建的所以只有一个选择//就是调用拷贝构造函数person2 person1; //调用operator函数//由于person2已经创建不需要再调用构造函数这时候调用的是重载的赋值运算符 } //2. 赋值重载案例 void test02(){Person person1(20, 20);Person person2(30, 30);cout person1: person1;cout person2: person2;person2 person1;cout person2: person2; } //常见错误当准备给两个相同对象赋值时应该首先检查一下这个对象是否对自身赋值了 //对于本例来讲无论如何执行这些赋值运算都是无害的但如果对类的实现进行修改那么将会出现差异 //3. 类中指针 class Person2{friend ostream operator(ostream os, const Person2 person){os Name: person.pName ID: person.mID Age: person.mAge endl;return os;} public:Person2(char* name,int id, int age){this-pName new char[strlen(name) 1];strcpy(this-pName, name);this-mID id;this-mAge age;} #if 1//重载赋值运算符Person2 operator(const Person2 person){//注意:由于当前对象已经创建完毕那么就有可能pName指向堆内存//这个时候如果直接赋值会导致内存没有及时释放if (this-pName ! NULL){delete[] this-pName;}this-pName new char[strlen(person.pName) 1];strcpy(this-pName,person.pName);this-mID person.mID;this-mAge person.mAge;return *this;} #endif//析构函数~Person2(){if (this-pName ! NULL){delete[] this-pName;}} private:char* pName;int mID;int mAge; };void test03(){Person2 person1(John,20, 20);Person2 person2(Edward,30, 30);cout person1: person1;cout person2: person2;person2 person1;cout person2: person2; }等于和不等于(、!)运算符重载 class Complex{ public:Complex(char* name,int id,int age){this-pName new char[strlen(name) 1];strcpy(this-pName, name);this-mID id;this-mAge age;}//重载号操作符bool operator(const Complex complex){if (strcmp(this-pName,complex.pName) 0 this-mID complex.mID this-mAge complex.mAge){return true;}return false;}//重载!操作符bool operator!(const Complex complex){if (strcmp(this-pName, complex.pName) ! 0 || this-mID ! complex.mID || this-mAge ! complex.mAge){return true;}return false;}~Complex(){if (this-pName ! NULL){delete[] this-pName;}} private:char* pName;int mID;int mAge; }; void test(){Complex complex1(aaa, 10, 20);Complex complex2(bbb, 10, 20);if (complex1 complex2){ cout 相等! endl; }if (complex1 ! complex2){ cout 不相等! endl; } } 函数调用符号()重载 class Complex{ public:int Add(int x,int y){return x y;}int operator()(int x,int y){return x y;} }; void test01(){Complex complex;cout complex.Add(10,20) endl;//对象当做函数来调用cout complex(10, 20) endl; } 不要重载、|| 不能重载 operator 和 operator|| 的原因是无法在这两种情况下实现内置操作符的完整语义。即不能实现短路特性 符号重载建议
http://www.yutouwan.com/news/304590/

相关文章:

  • 旅游网站模板图片睢县做网站的公司
  • 成都专业网站设计免费咨询公司官网制作需要多少钱一个
  • 做博客网站什么蓝色 适合公司网站主色
  • 怎么制作购物网站免费ppt模板 网站开发
  • 长春网络建站模板房地产网站开发公司
  • 怎样防止别人利用自己的电脑做网站服务器北京交友最好的网站建设
  • 现在主流网站用什么做的专做hip hop音乐的网站
  • php个人网站源码下载弄几个的网站
  • 网站维护案例分析wordpress翻页显示404
  • 惠州网页建站模板网站开发 避免 字段变化 代码
  • wordpress怎么安装插件珠海网站seo
  • wordpress如何加入备案许可证编号番禺seo
  • 网站html静态化解决方案网站优化怎么学
  • 做彩票平台网站吗办公室装修设计招商
  • 如何抄袭网站网站技巧
  • 中冶东北建设最新网站百度网站安全检测
  • 台州公司网站建设wordpress微信图片
  • 手机建设中网站页面设计是什么专业
  • 河南省汝州市建设网站郑州专业的网站建设公司哪家好
  • 做熊猫tv网站的目的禁止wordpress历史版本
  • 郫县做网站网站做301重定向怎么做
  • 做网站被用作非法用途做一个网站以及app多少钱
  • 做网站建设需要会哪些网站认证方式有几种
  • 什么网站可以教做面包旅游公司网站建设
  • wordpress 设置网站目录湖北网络广播电视台
  • 经营网站需要注意什么ps做网站显示内容参考
  • 网站首页导航栏建设网站流程图
  • 杭州网站关键词排名开发公司前期手续流程
  • 怎么搭建php网站站长素材音效
  • 渝快办官方网站宿迁房产网官网