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

  • 4
  • 0
  • 约1.3万字
  • 约 56页
  • 2016-12-09 发布于湖北
  • 举报
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 d

文档评论(0)

1亿VIP精品文档

相关文档