Chapter 10 Defining Classes. Chapter 10 Defining Classes.

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

Copyright © 2003 Pearson Education, Inc. Slide 1.
1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
CS 106 Introduction to Computer Science I 04 / 11 / 2008 Instructor: Michael Eckmann.
Inheritance Part I. Lecture Objectives To learn about inheritance To understand how to inherit and override superclass methods To be able to invoke superclass.
I NHERITANCE Chapter 10. I NHERITANCE Mechanism for enhancing existing classes You need to implement a new class You have an existing class that represents.
Ch 12: Object-Oriented Analysis
Chapter 9 – Inheritance Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved.
CS 106 Introduction to Computer Science I 04 / 16 / 2010 Instructor: Michael Eckmann.
1 Chapter 7 Inheritance, Polymorphism, and Scope.
CS 106 Introduction to Computer Science I 11 / 15 / 2006 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 11 / 19 / 2007 Instructor: Michael Eckmann.
Inheritance and Subclasses in Java CS 21a: Introduction to Computing I Department of Information Systems and Computer Science Ateneo de Manila University.
Chapter 10: Inheritance 1. Inheritance  Inheritance allows a software developer to derive a new class from an existing one  The existing class is called.
CHAPTER 10 OBJECT INHERITANCE Introduction to Computer Science Using Ruby (c) 2012 Ophir Frieder et al.
Inheritance One of the biggest advantages of object-oriented design is that of inheritance. A class may be derived from another class, the base class.
Remarks  Can only manually release memory blocks allocated by new operator delete [] ptr; delete ptr;  Dynamically allocated variables and arrays will.
Inheritance Chapter 14. What is inheritance?  The ability to create a class from another class, the “parent” class, extending the functionality and state.
CS 106 Introduction to Computer Science I 04 / 13 / 2007 Friday the 13 th Instructor: Michael Eckmann.
1 A Student Guide to Object- Orientated Systems Chapter 4 Objects and Classes: the basic concepts.
OBJECT AND CLASES: THE BASIC CONCEPTS Pertemuan 8 Matakuliah: Konsep object-oriented Tahun: 2009.
Module 7: Object-Oriented Programming in Visual Basic .NET
CSE 501N Fall ‘09 15: Polymorphism October 22, 2009 Nick Leidenfrost.
1 Chapter 2 (Cont.) The BA’s Perspective on Object Orientation.
Inheritance CSC 171 FALL 2004 LECTURE 18. READING Read Horstmann, Chapter 11.
John Byrne Inheritance Bank account examples. John Byrne Example account hierarchy F account relationships: ACCOUNT SAVINGSCHEQUE TIME_ACCT.
Copyright © 2012 Pearson Addison-Wesley. All rights reserved. Chapter 10 Defining Classes.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 10 Defining Classes.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Encapsulation ◦ Blackbox concept Data and method(s) Hidden details InterfaceEffect(s) methods called class.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 10 Defining Classes.
Basic Concepts of OOP.  Object-Oriented Programming (OOP) is a type of programming added to php5 that makes building complex, modular and reusable web.
BANK RESEARCH MAKE A TABLE WITH THE FOLLOWING INFORMATION.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 10 Defining Classes.
Introduction Every program takes some data as input and generate processed data as out put . It is important to know how to provide the input data and.
Object Oriented Programming: Inheritance
Lecture 12 Inheritance.
Chapter 10 Defining Classes. Chapter 10 Defining Classes.
Chapter 10 Defining Classes
Advanced Object-Oriented Programming
10.2 Classes Copyright © 2008 Pearson Addison-Wesley. All rights reserved. 1.
COMP 2710 Software Construction Inheritance
Table of Contents Class Objects.
Phil Tayco Slide version 1.1 Created Oct 30, 2017
Computing with C# and the .NET Framework
An Introduction to Inheritance
Object Oriented Concepts
Lecture 14 - Abstract Classes
CSC 205 Java Programming II
Understanding Inheritance
Inheritance Basics Programming with Inheritance
Domain Class Diagram Chapter 4 Part 2 pp
Lecture 22 Inheritance Richard Gesick.
Chapter 1: Introduction
Object Oriented Programming: Inheritance
Adding a Program (Programs are the highest level of your organization’s offerings hierarchy: Program > Category > Class > Session) 1.) Enrichment tab >
Software Engineering System Modeling Chapter 5 (Part 1) Dr.Doaa Sami
Computer Programming with JAVA
a generalization is a relationship between a general thing (the
CHAPTER 1 Exploring Data
CHAPTER 1 Exploring Data
CHAPTER 1 Exploring Data
Software Engineering System Modeling Chapter 5 (Part 1) Dr.Doaa Sami
Fundaments of Game Design
CHAPTER 1 Exploring Data
CHAPTER 1 Exploring Data
Chapter 11 Class Inheritance
CHAPTER 1 Exploring Data
Adding a Care Class (Categories are the second level of your organization’s offerings hierarchy: Program > Category > Class > Session) 1.) Enrichment tab.
Presentation transcript:

Chapter 10 Defining Classes

Overview 10.1 Structures 10.2 Classes 10.3 Abstract Data Types 10.4 Introduction to Inheritance

Introduction to Inheritance 10.4 Introduction to Inheritance

Inheritance Inheritance refers to derived classes Derived classes are obtained from another class by adding features A derived class inherits the member functions and variables from its parent class without having to re-write them Example In Chapter 6 we saw that the class of input-file streams is derived from the class of all input streams by adding member functions such as open and close cin belongs to the class of all input streams, but not the class of input-file streams

Inheritance Example Natural hierarchy of bank accounts Most general: A Bank Account stores a balance A Checking Account “IS A” Bank Account that allows customers to write checks A Savings Account “IS A” Bank Account without checks but higher interest Accounts are more specific as we go down the hierarchy Each box can be a class

Inheritance Relationships The more specific class is a derived or child class The more general class is the base, super, or parent class If class B is derived from class A Class B is a derived class of class A Class B is a child of class A Class A is the parent of class B Class B inherits the member functions and variables of class A

Defining Derived Classes Give the class name as normal, but add a colon and then the name of the base class Objects of type SavingsAccount can access member functions defined in SavingsAccount or BankAccount class SavingsAccount : public BankAccount { … } Display 10.9 (1-3)

Section 10.4 Conclusion Can you Define object? Define class? Describe the relationship between parent and child classes? Describe the benefit of inheritance?

Chapter 10 -- End

Display 10.1 (1/2) Back Next

Display 10.1 (2/2) Back Next

Display 10.2 Back Next

Display 10.3 (1/2) Back Next

Display 10.3 (2/2) Back Next

Display 10.4 (1/2) Back Next

Display 10.4 (2/2) Back Next

Display 10.5 (1/4) Back Next

Display 10.5 (2/4) Back Next

Display 10.5 (3/4) Back Next

Display 10.5 (4/4) Back Next

Display 10.6 (1/3) Back Next

Display 10.6 (2/3) Back Next

Display 10.6 (3/3) Back Next

Display 10.7 (1/3) Back Next

Display 10.7 (2/3) Back Next

Display 10.7 (3/3) Back Next

Display 10.8 Back Next

Display 10.9 (1/3) Back Next

Display 10.9 (2/3) Back Next

Display 10.9 (3/3) Back Next