Nur*_*lan 7 c++ operator-keyword
我们有以下课程.我需要解释一些代码部分.
class CPoint3D
{
public:
double x, y, z;
CPoint3D (double dX = 0.0, double dY = 0.0, double dZ = 0.0)
: x(dX), y(dY), z(dZ) {}
//what means these lines of code?
CPoint3D operator + (const CPoint3D& point) const;
CPoint3D operator - (const CPoint3D& point) const;
CPoint3D operator * (double dFactor) const;
CPoint3D operator / (double dFactor) const;
};
Run Code Online (Sandbox Code Playgroud)
我想用
CPoint3D operator + (const CPoint3D& point) const;
函数我可以轻松地添加/减去/乘/除除CPoint3D
类的实例?
有人可以用例子解释一下吗?谢谢!