zoukankan      html  css  js  c++  java
  • 虚函数(单一继承)

     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 };

     --未完,待续

  • 相关阅读:
    在Jenkins中使用sonar进行静态代码检查
    privoxy自动请求转发到多个网络
    实现自动SSH连接
    云平台的微服务架构实践
    JHipster技术栈理解
    部署模式
    部署模式
    部署模式
    JHipster生成单体架构的应用示例
    JHipster生成微服务架构的应用栈(二)- 认证微服务示例
  • 原文地址:https://www.cnblogs.com/zhaoyaxing/p/8375722.html
Copyright © 2011-2022 走看看