C++学习笔记15:操作符重载的函数原型列表(推荐)
//普通四则运算
friend A operator +(const A & lhs, const A & rhs);
friend A operator -(const A & lhs, const A & rhs);
friend A operator *(const A & lhs, const A & rhs);
friend A operator /(const A & lhs, const A & rhs);
friend A operator %(const A & lhs, const A & rhs);
friend A operator *(const A & lhs, const int & rhs);//标量运算,如果存在
friend A operator *(const int & lhs, const A & rhs);//标量运算,如果存在 //关系操作符
friend bool operator == (const A & lhs, const A & rhs);
friend bool operator != (const A & lhs, const A & rhs);
friend bool operator < (const A & lhs, const A & rhs);
friend bool operator <= (const A & lhs, const A & rhs);
friend bool operator > (const A & lhs, const A & rhs);
friend bool operator >= (const A & lhs, const A & rhs); //逻辑操作符
friend bool operator || (const A & lhs, const A & rhs);
friend bool operator && (const A & lhs, const A & rhs);
bool A::operator!(); //正负操作符
A A::operator +();//取正
A A::operator -();//取负 //递增递减操作符
A & A::operator++();//前缀递增
A A::operator++(int);//后缀递增
A & A::operator--();//前缀递减
A A::operator--(int);//后缀递减 //动态存储管理操作符:全局或者成员函数均可
void * operator new(std::size_t size) throw(bad_alloc);
void * operator new(std::size_t size, const std::nothrow_t &) throw();
void * operator new(std::size_t size, void *base) throw();
void * operator new[](std::size_t size) throw(bad_alloc);
void operator delete(void *p);
void operator delete[](void *p); //赋值操作符
A & operator = (A &rhs);
A & operator = (const A & rhs);
A & operator = (A && rhs);
A & operator += (const A & rhs);
A & operator -= (const A & rhs);
A & operator *= (const A & rhs);
A & operator %= (const A & rhs);
A & operator &= (const A & rhs);
A & operator /= (const A & rhs);
A & operator |= (const A & rhs);
A & operator ^= (const A & rhs);
A & operator <<= (int n);
A & operator >>= (int n); //下标操作符
T & A::operator[] (int i);
const T & A::operator[](int i)const; //函数调用操作符
T A::operator()(...);//参数可选 //类型转换操作符
A::operator char *() const;
A::operator int() const;
A::operator double() const; //逗号操作符
T2 operator,(T1 t1, T2 t2);//不建议重载 //指针与选员操作符
A * A::operator & ();//取址操作符
A & A::operator *();//引领操作符
const A & A::operator *() const;//引领操作符
C * A::operator->();//选员操作符
const C * A::operator->() const;//选员操作符
C & A::operator->*(...);//选员操作符,指向类成员的指针 //流操作符
friend ostream & operator << (ostream &os, const A &a);
friend istream & operator >> (istream &is, A &a);
C++学习笔记15:操作符重载的函数原型列表(推荐)的更多相关文章
- OpenCV学习笔记(15)——更多的轮廓函数
凸缺陷,以及如何找到凸缺陷 找某一点到一个多边形的最短距离 不同形状的匹配 1.凸缺陷 前面已经设计了轮廓的凸包和凸性缺陷的概念.OpenCV中有一个函数cv2.convexityDefect()可以 ...
- SQL反模式学习笔记15 分组
目标:查询得到每组的max(或者min等其他聚合函数)值,并且得到这个行的其他字段 反模式:引用非分组列 单值规则:跟在Select之后的选择列表中的每一列,对于每个分组来说都必须返回且仅返回一直值. ...
- 并发编程学习笔记(15)----Executor框架的使用
Executor执行已提交的 Runnable 任务的对象.此接口提供一种将任务提交与每个任务将如何运行的机制(包括线程使用的细节.调度等)分离开来的方法.通常使用 Executor 而不是显式地创建 ...
- C++基础 学习笔记五:重载之运算符重载
C++基础 学习笔记五:重载之运算符重载 什么是运算符重载 用同一个运算符完成不同的功能即同一个运算符可以有不同的功能的方法叫做运算符重载.运算符重载是静态多态性的体现. 运算符重载的规则 重载公式 ...
- Ext.Net学习笔记15:Ext.Net GridPanel 汇总(Summary)用法
Ext.Net学习笔记15:Ext.Net GridPanel 汇总(Summary)用法 Summary的用法和Group一样简单,分为两步: 启用Summary功能 在Feature标签内,添加如 ...
- ES6学习笔记<二>arrow functions 箭头函数、template string、destructuring
接着上一篇的说. arrow functions 箭头函数 => 更便捷的函数声明 document.getElementById("click_1").onclick = ...
- python3.4学习笔记(二十) python strip()函数 去空格\n\r\t函数的用法
python3.4学习笔记(二十) python strip()函数 去空格\n\r\t函数的用法 在Python中字符串处理函数里有三个去空格(包括'\n', '\r', '\t', ' ')的函数 ...
- APUE学习笔记——10.9 信号发送函数kill、 raise、alarm、pause
转载注明出处:Windeal学习笔记 kil和raise kill()用来向进程或进程组发送信号 raise()用来向自身进程发送信号. #include <signal.h> int k ...
- Flutter学习笔记(4)--Dart函数
如需转载,请注明出处:Flutter学习笔记(4)--Dart函数 Dart是一个面向对象的语言,所以函数也是对象,函数属于Function对象,函数可以像参数一样传递给其他函数,这样便于做回调处理: ...
随机推荐
- matlab(数组、矩阵)
- [工作技能]SVN
有的时候SVN上传txt文本文件,会报是bin文件的错误,解决方式是在.subversion文件夹下的config文件中加这么一句 *.txt = svn:mime-type=text/plain;s ...
- 转:Nginx+Apache环境的安装与配置
转:http://www.server110.com/nginx/201404/8817.html 我们依然尽可能采用yum来安装我们需要的软件,由系统官方维护的软件,其安全性和稳定性都值得信赖,并且 ...
- JDE修改Grid列样式
Set Grid Color :to change the background color of a cell, row, column, or the entire control. Set Gr ...
- hdu 4628 Pieces
http://acm.hdu.edu.cn/showproblem.php?pid=4628 状态压缩DP 时间复杂度应该是 16*(2^32) 但是运行时要远小于这个数 所以加一定剪枝就可以过 代码 ...
- PowerMock使用遇到的问题——2
如果在测一个类的某一个方法时,这个方法还调用了此类的其他方法,那么如何指定其他方法的返回值呢? Partial mock local private method or public method i ...
- node.js安装及grunt插件,如何进行脚本压缩
http://gruntjs.com/pluginshttp://gruntjs.com/getting-startedhttp://gruntjs.com/configuring-tasks#glo ...
- 仿淘宝js图片切换
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- ubuntu 12.04安装TP-LINK TL-WN725N v2
用了一个上午,折腾完毕,分享如下. 1.先试了ndiswrapper和compat-wireless,各种不给力.后来看这篇博文<Ubuntu12.04下安装TL-WN322G+无线网卡驱动(R ...
- iOS如何生成.a文件
首先来谈谈为何要使用.a文件 Objective-c语言有.h .m 文件组成.静态库可以将 .m文件封装成一个.a文件,第三方应用程序只需要拿到这个.a文件和代码对应的.h文件即可使用静态库中封装的 ...