Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Object Oriented Programming Inheritance: Fundamentals and Applications
Object Oriented Programming Inheritance: Fundamentals and Applications
Object Oriented Programming Inheritance: Fundamentals and Applications
Ebook93 pages36 minutes

Object Oriented Programming Inheritance: Fundamentals and Applications

Rating: 0 out of 5 stars

()

Read preview

About this ebook

What Is Object Oriented Programming Inheritance


In object-oriented programming, inheritance refers to the process of building one object or class off of another object or class while preserving the functionality of the original object or class. The formation of a hierarchy of classes can also be characterized as the process of deriving new classes from existing ones, such as a super class or a base class, and then organizing those classes into a hierarchy. An object that is generated through inheritance, known as a "child object," inherits all of the characteristics and actions of its "parent object," with the following exceptions: the constructors, destructors, overloaded operators, and friend functions of the base class. This is the case with the majority of class-based object-oriented programming languages. Inheritance gives programmers the ability to construct classes that are built upon existing classes, to specify a new implementation while preserving the same behaviors, to reuse code, and to independently extend original software via public classes and interfaces. Inheritance also enables programmers to create classes that are built upon existing classes. A directed acyclic graph is produced when the relationships between objects or classes are established through inheritance.


How You Will Benefit


(I) Insights, and validations about the following topics:


Chapter 1: Inheritance (object-oriented programming)


Chapter 2: Class (computer programming)


Chapter 3: Method (computer programming)


Chapter 4: Object (computer science)


Chapter 5: Class-based programming


Chapter 6: Method overriding


Chapter 7: Interface (Java)


Chapter 8: Object-oriented design


Chapter 9: Object-oriented programming


Chapter 10: Multiple inheritance


(II) Answering the public top questions about object oriented programming inheritance.


(III) Real world examples for the usage of object oriented programming inheritance in many fields.


(IV) 17 appendices to explain, briefly, 266 emerging technologies in each industry to have 360-degree full understanding of object oriented programming inheritance' technologies.


Who This Book Is For


Professionals, undergraduate and graduate students, enthusiasts, hobbyists, and those who want to go beyond basic knowledge or information for any kind of object oriented programming inheritance.

LanguageEnglish
Release dateJun 26, 2023
Object Oriented Programming Inheritance: Fundamentals and Applications

Related to Object Oriented Programming Inheritance

Titles in the series (100)

View More

Related ebooks

Intelligence (AI) & Semantics For You

View More

Related articles

Reviews for Object Oriented Programming Inheritance

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Object Oriented Programming Inheritance - Fouad Sabry

    Chapter 1: Inheritance (object-oriented programming)

    In object-oriented programming, inheritance is a mechanism for constructing an object or class from another object or class while maintaining a similar implementation (prototype-based inheritance). Another definition includes creating new classes (sub classes) by deriving them from more established ones, such as base or super classes, and then organizing them into a hierarchy of classes. With the exception of constructors, destructors, overloaded operators, and friend functions of the base class, an object created through inheritance, known as a child object, inherits all of the properties and behaviors of the parent object in the majority of class-based object-oriented programming languages. Through the usage of public classes and interfaces, programmers can independently modify original software by building new classes on top of pre-existing ones, specifying a new implementation while preserving the same behaviors (realizing an interface). A directed acyclic graph is created by the inheritance relationships between objects or classes.

    A class that has been inherited is known as a subclass of its parent class or super class. Both class-based and prototype-based programming use the term inheritance in a broad sense, but in a limited sense it only refers to class-based programming (where one class inherits from another), while the similar approach in prototype-based programming is known as delegation (one object delegates to another). Simple network interface parameters can be used to pre-define class-modifying inheritance patterns, preserving inter-language compatibility.

    The opposite of object composition, which is one object inside another (or objects of one class inside objects of another class), is object inheritance. In contrast to the is-a relationship of subtyping, composition implements a has-a relationship.

    Tony Hoare made several observations on records in 1966, and he particularly put forth the concept of record subclasses, which are record types with shared features that are distinguished by a variant tag and have fields that are exclusive to the variant. Smalltalk, C++, Java, Python, and many more languages later adopted the concept.

    There are numerous inheritance kinds, depending on the paradigm and the target language.

    Single inheritance

    where features from a single superclass are inherited by subclasses. A class gains access to the attributes of another class.

    Multiple inheritance

    where one class can inherit characteristics from all parent classes and have more than one superclass.

    It was widely believed that efficiently implementing multiple inheritance would be extremely challenging. For instance, Brad Cox expressly asserted that introducing multiple inheritance to C++ was unfeasible in his explanation of the language in his book on Objective C. Multiple inheritance hence seemed more difficult. I couldn't resist the challenge because I had thought about multiple inheritance as early as 1982 and discovered a straightforward and effective implementation method in 1984. I believe this is the only instance in which the order of events was influenced by fashion.

    — Bjarne Stroustrup

    Multilevel inheritance

    where one subclass inherits from another. A class may occasionally be descended from another descended class, as depicted in the figure Multilevel inheritance..

    The derived class B uses the class A as a base class, and the derived class C uses the class B as a base class. Because it serves as a bridge for the inheritance between classes A and C, class B is referred to as an intermediate base class. The inheritance path is the sequence ABC.

    The following declares a derived class with multilevel inheritance:

    class A { ... }; // Base class

    class B : public A { ... }; // B derived from A

    class C : public B { ... }; // C derived from B

    Any number of levels can be added to this process.

    Hierarchical inheritance

    Here, one class acts as the superclass (base class) for multiple subclasses. As an illustration, the parent class A may have the two subclasses B and C. A is the parent class of both B and C, although B and C are different subclasses.

    Hybrid inheritance

    When two or more of the aforementioned inheritance categories combine, this is known as hybrid inheritance. This can be seen, for instance, when class A has subclass B, which in turn contains the subclasses C and D. Hierarchical inheritance and multilevel inheritance are both combined in this.

    Modular derivative classes that inherit one or more language entities from one or more other classes are known as subclasses, derived classes, heir classes, or child classes (called superclass, base classes, or parent classes). Language to language, the meaning of class inheritance varies, but typically, a subclass immediately inherits the instance variables and member functions of its superclasses.

    When defining a derived class, the general format is:

    class SubClass: visibility SuperClass

    {

    // subclass members

    }; The colon denotes inheritance from the superclass, which the subclass derives from. If present, the visibility is optional and can be either private or public. Private is the default visibility setting. If the base class's features are privately derived or publicly derived, visibility indicates that.

    Other constructs can be inherited in some languages. For instance, in Eiffel, contracts that specify a class's specification are also passed down to successors. Specialized subclasses can inherit, alter, and augment the superclass's common interface and basic functionality. A subclass's use of

    Enjoying the preview?
    Page 1 of 1