






















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An introduction to inheritance and polymorphism in Object-Oriented Programming (OOP). It explains the principles of encapsulation, inheritance, and polymorphism, and discusses access specifiers, UML diagrams, and the life cycle of inheritance. It also covers the differences between is-a and has-a relationships, friend functions and classes, and overriding member functions.
What you will learn
Typology: Study notes
1 / 30
This page cannot be seen from the preview
Don't miss anything!
Object Oriented Programming
Inheritance
Derived Class Definition
example: base.cpp
UML Diagram Basics
UML Diagram Basics
Employee
UML Diagram Basics
GenericItem
ProduceItem
Base Class Derived Class https://learn.zybooks.com/zybook/SMUCS1342Spring2020/chapter/13/section/
Access Specifiers
Life Cycle of Inheritance Unlike other member functions within a class, Constructors and Destructors are NOT inherited by a derived class. Example Constructor: When an object is created:
Life Cycle of Inheritance Inheritance Constructor: When an object is created (with inheritance):
Single Inheritance
class DerivedClass: public Base { }
Multiple Inheritance Multiple Inheritance: Multiple Inheritance is a feature of C++ where a class can inherit from more than one classes. i.e one sub class is inherited from more than one base classes. class DerivedClass: public Base1, public Base2 { }
Hierarchical Inheritance Hierarchical Inheritance : In this type of inheritance, more than one sub class is inherited from a single base class. i.e. more than one derived class is created from a single base class. class DerivedClass1: public Base { } class DerivedClass2: public Base { }
Is-a vs Has-a Relationship
example: abstract.cpp