用C++解决问题第十版-第15章遗产.pptVIP

  • 3
  • 0
  • 约2.05万字
  • 约 78页
  • 2022-03-12 发布于湖北
  • 举报
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Display 15.3 (1/2) Slide 15- * Back Next Display 15.3 (2/2) Slide 15- * Back Next Display 15.4 Slide 15- * Back Next Display 15.5 Slide 15- * Back Next Display 15.6 (1/2) Slide 15- * Back Next Display 15.6 (2/2) Slide 15- * Back Next Display 15.7 (1/2) Slide 15- * Back Next Display 15.7 (2/2) Slide 15- * Back Next Display 15.8 (1/2) Slide 15- * Back Next Display 15.8 (2/2) Slide 15- * Back Next Display 15.9 Slide 15- * Next Back Display 15.10 Slide 15- * Back Next Display 15.11 Slide 15- * Next Back Display 15.12 Slide 15- * Back Next Display 15.13 (1/2) Slide 15- * Back Next Display 15.13 (2/2) Slide 15- * Back Next * * * * * * * * * * * * * * * * The Assignment Operator In implementing an overloaded assignment operator in a derived class: It is normal to use the assignment operator from the base class in the definition of the derived classs assignment operator Recall that the assignment operator is written as a member function of a class Slide 15- * The Operator = Implementation This code segment shows how to begin the implementation of the = operator for a derived class: Derived Derived::operator= (const Derived rhs) { Base::operator=(rhs) This line handles the assignment of the inherited member variables by calling the base class assignment operator The remaining code would assign the member variables introduced in the derived class Slide 15- * The Copy Constructor Implementation of the derived class copy constructor is much like that of the assignment operator: Derived::Derived(const Derived object) :Base(object), other initializing {…} Invoking the base class copy constructor sets up the inherited member variables Since object is of type Derived it is also of type Base Slide 15- * Destructors in Derived Classes If the base class has a working destructor, defining the destructor for the def

文档评论(0)

1亿VIP精品文档

相关文档