第11讲运算符重载分解.ppt

* 本节作业 P298 8-1、8-9P299 8-7 * 使用友员运算符重载的问题 首先看一个三维坐标点类的设计,例4: class Point3D private: int x , y , z ; public : Point3D operator + Point3D t ; // 重载“+” Point3D operator ++ ; // 重载“++” void show ; void assign int mx , int my , int mz ; ; * Point3D Point3D :: operator + Point3D t Point3D temp ; temp . x x + t . x ; temp . y y + t . y ; temp . z z + t . z ; return temp ; Point3D Point3D :: operator + + x + + ; y + + ; z + + ; return * this ; void Point3D :: show cout x “ , ” y “ , ” z “\n” ; void Point3D :: assign int mx , in

文档评论(0)

1亿VIP精品文档

相关文档