| Website for students | VTU NOTES

Slides:



Advertisements
Similar presentations
Chapter 5 Inheritance. Objectives Introduction, effects, and benefits of inheritance Base class and derived class objects Base class and derived class.
Advertisements

Inheritance. Many objects have a hierarchical relationship –Examples: zoo, car/vehicle, card game, airline reservation system Inheritance allows software.
Chapter 1 Inheritance University Of Ha’il.
INHERITANCE BASICS Reusability is achieved by INHERITANCE
LOGO Lecturer: Abdullahi Salad Abdi May 1, Object Oriented Programming in C++
Inheritance and Polymorphism CS351 – Programming Paradigms.
Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 Inheritance Inheritance is a fundamental object-oriented design technique used to.
Stream Handling Streams - means flow of data to and from program variables. - We declare the variables in our C++ for holding data temporarily in the memory.
Inheritance Inheritance – most important and a useful feature of OOPs supported by C++ | Website for Students | VTU -NOTES -Question Papers.
Chapter 8 More Object Concepts
OOP IN PHP `Object Oriented Programming in any language is the use of objects to represent functional parts of an application and real life entities. For.
Inheritance Building one object from another. Background Object-oriented programming is normally described has offering three capabilities Encapsulation:
Chapter 7 Understanding Inheritance. LOGO Objectives  Learn about inheritance and its benefits  Create a derived class  Learn about restrictions imposed.
8. Inheritance “Is-a” Relationship. Topics Creating Subclasses Overriding Methods Class Hierarchies Abstract Class Inheritance and GUIs The Timer Class.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Inheritance Inheritance allows a programmer to derive a new class from an existing one The existing class is called the super class, or parent class,
Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Ramez Elmasri and Shamkant Navathe Enhanced-ER (EER) Model Concepts.
A class may de defined to automatically include the data members and member functions of an already existing class. New data members and member functions.
Classes, Interfaces and Packages
Chapter 4_part2: The Enhanced Entity-Relationship (EER) Model.
Java Programming Fifth Edition Chapter 9 Introduction to Inheritance.
Data Structures Lecture 4: Classes in C++ Azhar Maqsood NUST Institute of Information Technology (NIIT)
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Java Generics.
Enhanced Entity-Relationship and Object Modeling Objectives
© Shamkant B. Navathe CC.
Session 2 Welcome: The sixth learning sequence
Objects as a programming concept
Final and Abstract Classes
Inheritance and Polymorphism
Chapter 2: Entity-Relationship Model
OBJECT ORIENTED PROGRAMMING II LECTURE 7 GEORGE KOUTSOGIANNAKIS
COMP 2710 Software Construction Inheritance
Inheritance Inheritance allows a programmer to derive a new class from an existing one The existing class is called the super class, or parent class,
Inheritance in Java.
Week 4 Object-Oriented Programming (1): Inheritance
Road Map Inheritance Class hierarchy Overriding methods Constructors
Chapter 13 Abstract Classes and Interfaces
Chapter 10 Thinking in Objects
Chapter 14 Inheritance Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Inheritance Basics Programming with Inheritance
Comp 249 Programming Methodology
© Shamkant B. Navathe CC.
Java Programming Language
MSIS 670 Object-Oriented Software Engineering
Inheritance Dr. Bhargavi Goswami Department of Computer Science
IS437: Fall 2004 Instructor: Dr. Boris Jukic
Inheritance.
Advanced Programming Behnam Hatami Fall 2017.
More Object-Oriented Programming
© Shamkant B. Navathe CC.
Computer Programming with JAVA
9: POLYMORPHISM Programming Technique II (SCSJ1023) Jumail Bin Taliba
Derived Classes in C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition,
CS4222 Principles of Database System
Java Programming, Second Edition
CMSC 202 Generics.
Inheritance.
Sampath Jayarathna Cal Poly Pomona
Inheritance and Polymorphism
Interfaces.
© Shamkant B. Navathe CC.
Inheritance -I.
CMSC202 Computer Science II for Majors Lecture 10 and 11 – Inheritance
C++ Programming CLASS This pointer Static Class Friend Class
Enhanced Entity-Relationship (EER) Modeling
C++ Object Oriented 1.
Programming in C# CHAPTER 5 & 6
Presentation transcript:

www.bookspar.com | Website for students | VTU NOTES Inheritance Inheritance – most important and a useful feature of OOPs supported by C++

Inheritance – process of creating new class from the existing class. www.bookspar.com | Website for students | VTU NOTES Inheritance – process of creating new class from the existing class. New class is called the Derived class / Child class /subclass Existing class is called the Base class / Parent class / Super class. Derived Class derives or inherits the features of existing class. It contains features of existing class and some of its own features. Base class is the original class that remains unchanged and features of exising class is fully or partially inherited.

Syntax for derivation : www.bookspar.com | Website for students | VTU NOTES Syntax for derivation : class <name of derived class> : <access specifier> <name of base class> { /*definition of derived class*/ }

www.bookspar.com | Website for students | VTU NOTES Suppose class A already exists. Then a class B is derived from class A as follows Class B : public A { /*new features of class B*/ }; Public access specifier is used in the foregoing example

www.bookspar.com | Website for students | VTU NOTES A pointer from derived class to the base class diagrammatically shows derivation Diagrammatic depiction of Inheritance A B

Effects of inheritance www.bookspar.com | Website for students | VTU NOTES Effects of inheritance Inheritance affects the size and behavior of the derived class objects in 2 ways An object of derived class contain all data members of the derived class. It contains data members of the base class also. Hence an object of derived class will always be larger than object of base class.

www.bookspar.com | Website for students | VTU NOTES With respect to an object of the derived class, we can call public member functions of the derived class in any global non-member function. However we can call public member functions of the base class also with exceptions.

www.bookspar.com | Website for students | VTU NOTES An object of derived class will contain the data members of the base class and data members of the derived class. Hence the size of object of derived class = sum of the sizes of data members of the base class + sum of sizes of the data members of the derived class.

www.bookspar.com | Website for students | VTU NOTES Inheritance implements an ‘is-a’ relationship. A derived class is a type of the base class like an aircraft (derived class) is a type of vehicle (base class). A class may contain an object of another class / pointer to datastructure that contain set of objects of another class. Such a class is called container class

www.bookspar.com | Website for students | VTU NOTES Eg – An aircraft has 1 engine or an array of engines. Another eg – manager class & employee class. A manager (i.e. an object of the class manager) is an employee (i.e. object of class employee). It has some features that are not possessed by an employee.

www.bookspar.com | Website for students | VTU NOTES Eg – it may have a pointer to an array of employees that report to him. Derived class object is also a base class object shown in the code.

www.bookspar.com | Website for students | VTU NOTES Class Employee { String name; Double basic; Date doj; /*rest of employee class*/ };

www.bookspar.com | Website for students | VTU NOTES Class manager : public employee { employee *list; /*rest of the class manager*/ }