1 / 11

Implementing Inheritance

Implementing Inheritance. About OOP Object oriented programming is a tool for new challenges in software development offers a closer fit to the way human think improves communication improves the quality of software. Important OOP concepts:. • Encapsulation • Data hiding

wade-diaz
Download Presentation

Implementing Inheritance

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Implementing Inheritance

  2. About OOP Object oriented programming is a tool for new challenges in software development • offers a closer fit to the way human think • improves communication • improves the quality of software

  3. Important OOP concepts: • Encapsulation • Data hiding • Polymorphism • Inheritance

  4. Inheritance It is the capability of one class to inherit properties from other class.

  5. Implementing Inheritance Inheritance is implemented by specifying the name of the base class from which the class being defined (derived class) has to inherit from. Class <class name> : <base class name> { derived class own features }

  6. Different forms of Inheritance Single Inheritance Multiple Inheritance Hierarchical Inheritance Multilevel Inheritance

  7. Single Inheritance Class derived class name : visibility-mode base class name { //members of derived class }

  8. Visibility mode The visibility mode controls the visibility and availability of inherited base members in the derived class. It controls the access specifier to be, for inheritable members of base class, in he derived class.

  9. Relationship of Inheritance and visibility modes Class base Not inheritable Class d2 : private base Class d1 : public base Class z: public d1, private d2

  10. Visibility Modes

  11. Name the members, which can be accessed from the member functions of class human. • Name the members, which can be accessed by an object of class human. • What will be the size of an object of class human? Class ape{ int organs, bones; public: void readape(); void showape(); }; Class human : public ape { char race[20]; char habitation[25]; public: void readhuman(); void showhuman(); };

More Related