Chapter 11 Class Inheritance

Slides:



Advertisements
Similar presentations
Chapter 1 OO using C++. Abstract Data Types Before we begin we should know how to accomplish the goal of the program We should know all the input and.
Advertisements

Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Inheritance.
C++ Training Datascope Lawrence D’Antonio Lecture 3 An Overview of C++
OOP Spring 2007 – Recitation 71 Object Oriented Programming Spring 2006 Recitation 8.
Static and Dynamic Behavior Fall 2005 OOPD John Anthony.
OOP Etgar 2008 – Recitation 71 Object Oriented Programming Etgar 2008 Recitation 7.
© 2006 Pearson Addison-Wesley. All rights reserved9 A-1 Chapter 9 Advanced Java Topics CS102 Sections 51 and 52 Marc Smith and Jim Ten Eyck Spring 2007.
1 Chapter 14-2 Object- Oriented Software Development Dale/Weems.
Programming Languages and Paradigms Object-Oriented Programming.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Learners Support Publications Pointers, Virtual Functions and Polymorphism.
1 Classes- Inheritance Multiple Inheritance It is possible to derive a new class from more than one base class. This is called Multiple Inheritance. Under.
Chapter 15 – Inheritance, Virtual Functions, and Polymorphism
Polymorphism. Introduction ‘one name multiple forms’ Implemented using overloaded functions and operators Early binding or static binding or static linking.
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
CONCEPTS OF OBJECT ORIENTED PROGRAMMING. Topics To Be Discussed………………………. Objects Classes Data Abstraction and Encapsulation Inheritance Polymorphism.
Specialization and Inheritance Chapter 8. 8 Specialization Specialized classes inherit the properties and methods of the parent or base class. A dog is.
Inheritance in the Java programming language J. W. Rider.
OOP: Encapsulation,Abstraction & Polymorphism. What is Encapsulation Described as a protective barrier that prevents the code and data being randomly.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 8: Class Relationships Data Abstraction & Problem Solving.
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
Chapter 10 Classes and Objects In-Depth. Chapter 10 A class provides the foundation for creating specific objects, each of which shares the general attributes,
Advanced C++ Topics Chapter 8. CS 308 2Chapter 8 -- Advanced C++ Topics This chapter describes techniques that make collections of reusable software components.
Class Relationships And Reuse Interlude 4 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
Chapter -6 Polymorphism
CS212: Object Oriented Analysis and Design Lecture 16: Runtime Polymorphism.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
Inheritance in C++ Bryce Boe 2012/08/28 CS32, Summer 2012 B.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
Polymorphism Lecture - 9.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Classes C++ representation of an object
© 2017 Pearson Education, Hoboken, NJ. All rights reserved
Inheritance Allows extension and reuse of existing code
Polymorphism, Abstract Classes & Interfaces
OOP What is problem? Solution? OOP
Class A { public : Int x; A()
Object-Oriented Programming
CS212: Object Oriented Analysis and Design
Table of Contents Class Objects.
Types of Programming Languages
Advanced C++ Topics Chapter 8.
Object Oriented Concepts
C++ Classes C++ Interlude 1.
Object Orientation Yaodong Bi, Ph.D. Department of Computer Sciences
Object Oriented Programming
Object Oriented Analysis and Design
Inheritance Basics Programming with Inheritance
OOP and ADTs Chapter 14 Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved.
Java Programming Language
Abstract Classes AKEEL AHMED.
Advanced Java Topics Chapter 9
Polymorphism CT1513.
Separating Definition & Implementation
Polymorphism, Abstract Classes & Interfaces
Polymorphism Polymorphism
Computer Programming with JAVA
Virtual Functions Polymorphism is supported by C++ both at compile time and at run time. Compile-time polymorphism is achieved by overloading functions.
Chapter 11: Inheritance and Composition
Chapter 8: Class Relationships
Chapter 6 Polymorphism.
Classes C++ representation of an object
Ninth step for Learning C++ Programming
Jim Fawcett CSE687 – Object Oriented Design Spring 2014
Object Oriented Programming(OOP)
C++ Object Oriented 1.
Static Binding Static binding chooses the function in the class of the base class pointer, ignoring any versions in the class of the object actually.
Computer Science II for Majors
Presentation transcript:

Chapter 11 Class Inheritance

Chapter 11 Inheritance is that property of object-oriented programming that allows one class, called a derived class, to share the structure and behavior of another class, called a base class.

Chapter 11 A family of bank account classes

Chapter 11 The important link between a derived class and its base class is the IS-A link. For instance, a checking account IS-A bank account. The IS-A relationship must exist if inheritance is used properly. If there is no IS-A relationship, inheritance should not be used.

Chapter 11 Format for Declaring Derived Classes class derived class : public base class { Derived Class Member Functions Derived Class Member Data }; //END CLASS

Chapter 11 A protected member of a class is a member that is accessible to both the base class and any derived classes of the base class in which it is declared. Use the keyword protected when declaring a member of a class if you want to allow access to the member by a derived class. The # symbol is used in UML to denote a protected class member.

Chapter 11 An abstract class is a base class for which objects will never be created.

Chapter 11 A public base class allows all public members of the base class to be public in the derived class.

Chapter 11 Single inheritance occurs when the inherited class members can be traced back to a single parent class. Multiple inheritance occurs when the inherited class members can be traced back to more than one parent class.

Chapter 11 Use #ifndef When Declaring Base Classes in C++, as follows: #ifndef HEADER FILE NAME_H #define HEADER FILE NAME _H BASE CLASS DECLARATION #endif

Chapter 11 The term polymorphic is Greek meaning “of many forms.” A polymorphic function is one that has the same name for different classes of the same family, but has different implementations, or behavior, for the various classes.

Chapter 11 Dynamic, or late, binding occurs when a polymorphic function is defined for several classes in a family but the actual code for the function is not attached, or bound, until execution time. A polymorphic function that is dynamically bound is called a virtual function.

Chapter 11 Static binding occurs when a polymorphic function is defined for several classes in a family and the actual code for the function is attached, or bound, at compile time. Overloaded functions are statically bound.