首页 > 编程 > C++ > 正文

c++运算符重载

2019-11-08 19:50:56
字体:
来源:转载
供稿:网友
c++可以通过对自定义类的运算符重载使得自定义类可以像int string等一样方便地进行+ - × / 和输入输出等操作,类的运算符重载方式可以通过定义成员函数或者通过友元函数的方式重载,其中运算符<<和>>只能通过友元函数的方式重载,http://en.cpPReference.com/w/cpp/language/Operators 这里解释道:Since they take the user-defined type as the right argument (b in a@b), they must be implemented as non-members. 另外可以看msdn: https://msdn.microsoft.com/en-us/library/1z2f6c2k.aspx
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选