c++课件-第八章-继承和派生简化版New.pptVIP

  • 1
  • 0
  • 约2.62万字
  • 约 100页
  • 2017-06-05 发布于浙江
  • 举报
* public: TCircle(int mx=0, int my=0, int mr=1): TShape(mx, my) { r = mr; } void Show() {TShape::Show();cout\tr=r; } }; int main(){ TShape s; TCircle c(1,2,3); ? coutTShape s\t; s.Show(); coutendl; coutTCircle c\t; c.Show(); coutendl; ? s = c; //用派生类对象为基类对象赋值 // s = static_castTShape(c); couts=c\t\t; s.Show(); coutendl; return 0; } //Main08.cpp #include iostream using namespace std; class TShape { protected: int x, y; public: TShape(int mx=0, int my=0) { x=mx; y=my; } void Show() {coutx=x\t y=y;} }; class TCircle : public

文档评论(0)

1亿VIP精品文档

相关文档