C面向对象程序设计谭浩强第二章.pptVIP

  • 18
  • 0
  • 约8.3千字
  • 约 31页
  • 2019-06-26 发布于浙江
  • 举报
2.6 类的封装和信息隐蔽 // rectangle.h class rectangle { private: int length, width; public: void Put ( ); void display ( ); }; // rectangle.cpp #include iostream.h #include “rectangle.h” void rectangle::Put ( ) { length = 5; width = 4; } void rectangle:: display ( ) { cout “area = “ length*width endl; } // main.cpp #include iostream.h #include “rectangle.h” void main ( ) { rectangle r1; r1.display ( ); } * C++

文档评论(0)

1亿VIP精品文档

相关文档