xt12-3-2.cpp
上传用户:liubin
上传日期:2022-06-13
资源大小:85k
文件大小:0k
源码类别:

书籍源码

开发平台:

Visual C++

  1. #include <iostream>
  2. using namespace std;
  3. class Point
  4. {public:
  5.   Point(float a,float b):x(a),y(b){}
  6.   ~Point(){cout<<"executing Point destructor"<<endl;}
  7.  private:
  8.   float x;
  9.   float y;
  10. };
  11. class Circle:public Point
  12. {public:
  13. Circle(int a,int b,int r):Point(a,b),radius(r){}
  14.   ~Circle(){cout<<"executing Circle destructor"<<endl;}
  15.  private:
  16.   float radus;
  17. };
  18. int main()
  19. {Point *p=new Circle(2.5,1.8,4.5);
  20.  Circle *pt=new Circle(2.5,1.8,4.5);
  21.  delete pt;
  22.  return 0;
  23. }