C++语言程序设计(清华大学)八.pptVIP

  • 8
  • 0
  • 约1.17万字
  • 约 54页
  • 2017-12-01 发布于山西
  • 举报
C++语言程序设计(清华大学)八.ppt

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Rectangle::Rectangle(double x, double y, double w, double h) :Point(x, y), w(w), h(h) { } void fun(const Point s) { cout Area = s.area() endl; } int main() { Rectangle rec(3.0, 5.2, 15.0, 25.0); fun(rec); return 0; } 运行结果: Area = 0 * #includeiostream using namespace std; class Point { public: Point(double x, double y) : x(x), y(y) { } virtual double area() const { return 0.0; } private: double x, y; }; class Rectangle:public Point { public: Rectangle(double x, double y, double w, double h); virtual doubl

文档评论(0)

1亿VIP精品文档

相关文档