• Point2和Point3类定义


    支持以下图中的运算

    类声明:

    class Point2 {
    public:
    	Point2();
    	~Point2();
    	Point2(ldouble a);
    	Point2(ldouble a, ldouble b);
    	Point2(const Point2& p);
    	Point2 operator+(const Point2& p) const;
    	Point2& operator+=(const Point2& p);
    	Point2 operator-(const Point2& p) const;
    	Point2& operator-=(const Point2& p);
    	Point2 operator*(ldouble a) const;
    	Point2& operator*=(ldouble a);
    	Point2 operator/(ldouble f) const;
    	Point2& operator/=(ldouble f);
    	Point2 operator-() const;
    	Point2& operator=(const Point2& p);
    	bool operator==(const Point2& p) const;
    	bool operator!=(const Point2& p) const;
    	friend ldouble distance(const Point2& p1, const Point2& p2);
    	friend ldouble distance_squared(const Point2& p1, const Point2& p2);
    	friend Point2 operator*(ldouble a, const Point2& p);
    	friend std::ostream& operator<<(std::ostream& os, const Point2& p);
    	friend std::istream& operator>>(std::istream& is, Point2& p);
    	ldouble x, y;
    };
    
    class Point3 {
    public:
    	Point3();
    	~Point3();
    	Point3(ldouble a);
    	Point3(ldouble a, ldouble b, ldouble c);
    	Point3(const Point2& p);
    	Point3(const Point3& p);
    	Point3 operator+(const Vector3& v) const;
    	Point3& operator+=(const Vector3& v);
    	Vector3 operator-(const Point3& p) const;
    	Point3 operator-(const Vector3& v) const;
    	Point3& operator-=(const Vector3& v);
    	Point3 operator*(ldouble a) const;
    	Point3& operator*=(ldouble a);
    	Point3 operator/(ldouble f) const;
    	Point3& operator/=(ldouble f);
    	Point3 operator-() const;
    	Point3& operator=(const Point3& p);
    	bool operator==(const Point3& p) const;
    	bool operator!=(const Point3& p) const;
    	friend ldouble distance(const Point3& p1, const Point3& p2);
    	friend ldouble distance_squared(const Point3& p1, const Point3& p2);
    	friend Point3 operator*(ldouble a, const Point3& p);
    	friend std::ostream& operator<<(std::ostream& os, const Point3& p);
    	friend std::istream& operator>>(std::istream& is, Point3& p);
    	ldouble x, y, z;
    };
    

      

    实现还是作为练习,图中已经写明了运算了。

  • 相关阅读:
    jquery中的 deferred之 deferred对象 (一)
    javascript函数嵌套时arguments的问题
    Jquery中的 Deferred分析
    Javascript面试题收集
    jquery中的callbacks之我见
    javascript正则表达式中 (?=exp)、(?<=exp)、(?!exp)
    javascript中正则表达式中的 match,exec,test,replace 之我理解
    删除域帐户/网络帐号密码 重新登录域服务器
    jQuery.extend 与 jQuery.fn.extend
    HttpMessageConvert
  • 原文地址:https://www.cnblogs.com/dalgleish/p/12602716.html
Copyright © 2020-2023  润新知