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
- Write A Program In C++ To Accept The Order Of Two Matrices, Check For The Possibility Of Multiplication, And Perform The Multiplication?
- What Is Indexed File Organization?
- How The Performance Of Database?
- How Is That The Additional Hardware Affect The Data Base Management System?
- How Do You Automate Starting And Shutting Down Of Databases In Unix?
- How Design An Algorithm For The SIMD Computer To Calculate The Sum Of An Array (A) Of 8 Elements. Assume That Element Ai Is Stored In The Local Memory Of PEi, Where I=1,2,3,.......4?
- Do I Have To Write A Main Method In Every Class I Create?Why?
- Do I Have To Write A Main Method In Every Class I Create?
- What Is Centralize Database Management System?
- Why We Indicate FF As 0FF In Program?
- When To Apply For Css?
- How Do I Enable Java On My I465?
- What Are Key Features Of Procedural Programming?
- What Is Conceptual Methodology?
- What Is Hierarchy Or Structure Of Database?
- Explain How Records And Related Records Are Deleted To Ensure The Integrity?
- I Am Non IT Professionals And Now I Want To Join MS Dynamics CRM. I Learnt Tha C# And ASP.net Is Must For That?
- What Is The Definition Of Hierarchical?
- What Is Rule Based Query?
- A B C D E A B C D A B C A B A Search Program For This Output (using For Loop)?
- How To Convert Binary To Octal In Java Programming?
- What Is Overloading In Java?
- Why Relations Should Not Have Transitive Dependency. Illustrate With Example?
- Create A Program That Displays Color Of An Item Whose Item Number Is Entered By User In C++?
- What Compression Programs Are Associated With Zip Sit And Exe File Extensions?
- How To Write Java Program To Calculate Student Grade Using Inheritance Concept?
- Can You Define The Concept Of Evolution?
- How Would You Define The Concept Of A Human Right?
- 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?

New Comment - Comments are editable for 5 min.