c++课件第11章高级函数.pptxVIP

  • 1
  • 0
  • 约7.71千字
  • 约 41页
  • 2017-01-05 发布于北京
  • 举报
第11章高级函数本章内容安排重载成员函数使用默认值初始化对象复制构造函数静态成员数据与静态成员函数友元函数与友元类--成员函数的重载在类中,可以定义多个同名的成员函数,但参数类型或个数不同,形成成员函数的重载关系。编译器根据调用成员函数时,所传递实参的类型决定调用哪个版本函数。不允许只通过返回值类型的不同形成重载关系。--Rectangle类class Rectangle{public: Rectangle(int newWidth, int newHeight) :width(newWidth), height(newHeight) { } ~Rectangle() {} void drawShape() const; void drawShape(int width, int height) const;private: int width; int height;};--重载成员函数的实现void Rectangle::drawShape() const{ drawShape(width, height);}void Rectangle::drawShape(int width, int height) const{ for (int i = 0; i height; i++) { for (int j = 0; j width; j++) std::cout *

文档评论(0)

1亿VIP精品文档

相关文档