1 Answer - Sort by: Date | Rating
The idea of classes leads to the idea of inheritance. In our daily lives, we use the concept of classes as divided into subclasses. We know that the class of animals is divided into mammals, amphibians, insects, birds, and so on. The class of vehicles is divided into cars, trucks, buses, and motorcycles.
The principle in this sort of division is that each subclass shares common characteristics with the class from which it's derived. Cars, trucks, buses, and motorcycles all have wheels and a motor; these are the defining characteristics of vehicles. In addition to the characteristics shared with other members of the class, each subclass also has its won particular characteristics: Buses, for instance, have seats for many people, while trucks have space for hauling heavy loads.
In a similar way, an OOP class can be divided into subclasses. In C++ the original class is called the base class; other classes can be defined that share its characteristics, but add their own as well. These are called derived classes.
Don't confuse the relation of objects to classes, on the one hand, with the relation of a base class to derived classes, on the other. Objects, which exist in the computer's memory, each embody the exact characteristics of their class, which serves as a template. Derived classes inherit some characteristics from their base class, but add new ones of their own.
Inheritance is somewhat analogous to using functions to simplify a traditional procedural program. If we find that three different sections of a procedural program do almost exactly the same thing, we recognize an opportunity to exact the common elements of these three sections and put them into a single function. The three sections of the program can call the function to execute the common actions, and they can perform their own individual processing as well. Similarly, a base class contains elements common to a group of derived classes. As functions do in a procedural program, inheritance shortens an object-program and clarifies the relationship among program elements.
The principle in this sort of division is that each subclass shares common characteristics with the class from which it's derived. Cars, trucks, buses, and motorcycles all have wheels and a motor; these are the defining characteristics of vehicles. In addition to the characteristics shared with other members of the class, each subclass also has its won particular characteristics: Buses, for instance, have seats for many people, while trucks have space for hauling heavy loads.
In a similar way, an OOP class can be divided into subclasses. In C++ the original class is called the base class; other classes can be defined that share its characteristics, but add their own as well. These are called derived classes.
Don't confuse the relation of objects to classes, on the one hand, with the relation of a base class to derived classes, on the other. Objects, which exist in the computer's memory, each embody the exact characteristics of their class, which serves as a template. Derived classes inherit some characteristics from their base class, but add new ones of their own.
Inheritance is somewhat analogous to using functions to simplify a traditional procedural program. If we find that three different sections of a procedural program do almost exactly the same thing, we recognize an opportunity to exact the common elements of these three sections and put them into a single function. The three sections of the program can call the function to execute the common actions, and they can perform their own individual processing as well. Similarly, a base class contains elements common to a group of derived classes. As functions do in a procedural program, inheritance shortens an object-program and clarifies the relationship among program elements.
0
0
- What Is Easy Way To Compute Factorial?
- Why Is Data More Secured In A Database?
- Java Programming How To Get The Sum Of Two Numbers?
- List And Describe Types Of Entrepreneurs?
- What Is Indexing In SQL?
- What Is Digitize?
- What Are The Three Fundamental Control Structures?
- What Is The Importance Of A Data Base For A Business?
- I Have Had A Website Created. How Do I Upload The File Onto My Domain Page?
- What Is A File In A Database?
- Where Is The Difference Between Wordpad, Notepad And MS Word?
- What Is Mean By Asp.net?
- List And Describe The ACID Properties For Database?
- What Is The Average Speed For This Data Entry Job?
- Why Do We Use Main() Function In C++?
- List And Describe The Different Types Of Database?
- What Is The Different Between Pointer Variable And Simple Variable? What Are The Advantage Of Pointer Variable.
- How To Use Commit And Rollback In Sql?
- What Are The Objectives Of Database Approach?
- What Are The Application Of The Pointers?
- What Are The Applications Of Pointers?
- Define Computer And Describe It's Operation?
- What Is Recursive Abstraction?
- What Is The Int Rest Rate On US I Bonds?
- Is Music Programming Important?
- How To Write Java Program To Calculate Student Grade Using Inheritance Concept?
- Can You Define The Concept Of Evolution?
- Define The Utility And Discuss The Various Concept Of Utility?
- Can You Define The Terrorism And Jihad,concept?
- How Do We Define Terms Psychological Self, Self-hood And Self-Concept?
- Can You Define Classes Concept In Object-Oriented Programming?
- Can You Define And Explain The Concept Of Jihad In And Outside The Islam House?

New Comment - Comments are editable for 5 min.