1 class Point { 2 public: 3 virtual ~Point(); 4 5 virtual Point & mult (float) = 0; 6 //..... 7 float x() const { return _x;} 8 virtual float y() const {return 0;} 9 virtual float z() const {return 0;} 10 11 protected: 12 Point( float x=0.0); 13 float _x; 14 }; 15 16 class Point2d : public Point{ 17 public: 18 Point2d (float x=0.0, float y=0.0) : Point(x), _y(y){} 19 20 ~Point2d(); 21 22 Point2d & mult (float); 23 float y() const {return _y;} 24 protected: 25 float _y; 26 }; 27 28 class Point3d : public Point2d{ 29 public : 30 Point3d (float x=0.0,float y=0.0, float z=0.0): Point2d(x,y), _z(z){} 31 ~Point3d(); 32 33 Point3d & mult(float); 34 float z() const { return _z;} 35 protected: 36 float _z; 37 };
--未完,待续