Inheritance Basics Fall 2008

Slides:



Advertisements
Similar presentations
Abteilung für Telekooperation Softwareentwicklung 2 UE SE2UE_ Vererbung (Inheritance)
Advertisements

Object-Oriented Programming
Inheritance Math 130 B Smith: Consider using the example in SAMS Teach Yourself C++ in 24 hours B Smith: Consider using the example in SAMS Teach Yourself.
C++ Classes & Data Abstraction
LOGO Lecturer: Abdullahi Salad Abdi May 1, Object Oriented Programming in C++
Inheritance Inheritance is the capability of one class of things to inherit the capabilities or properties from another class. Consider the example of.
Inheritance Concept of Inheritance (What, Why, and How) Simple Example of Inheritance Base Classes and Derived Classes Private Member Data vs. Protected.
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
You gotta be cool. Inheritance Base Classes and Derived Classes Inheritance: Public, Protected, Private What is inherited from the base class? Multiple.
CS 106 Introduction to Computer Science I 11 / 13 / 2006 Instructor: Michael Eckmann.
CS-2135 Object Oriented Programming
Inheritance COMP53 Sept Inheritance Inheritance allows us to define new classes by extending existing classes. A child class inherits all members.
16/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Concept originated with simulating objects and their interactions. Adapted.
CS 106 Introduction to Computer Science I 11 / 19 / 2007 Instructor: Michael Eckmann.
1 Inheritance Inheritance is a natural way to model the world in object-oriented programming. It is used when you have two types of objects where one is.
Virtual Functions Fall 2008 Dr. David A. Gaitros
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
Lecture 8 Inheritance Richard Gesick. 2 OBJECTIVES How inheritance promotes software reusability. The concepts of base classes and derived classes. To.
CS 106 Introduction to Computer Science I 04 / 11 / 2008 Instructor: Michael Eckmann.
©Fraser Hutchinson & Cliff Green C++ Certificate Program C++ Intermediate Access Control.
Python: Classes By Matt Wufsus. Scopes and Namespaces A namespace is a mapping from names to objects. ◦Examples: the set of built-in names, such as the.
2/9/98 Thomas O’Reilly 1 A Quick UML Introduction.
Chapter 10 Inheritance and Polymorphism
Aggregation/Composition Programming in C++ Fall 2008 Dr. David A. Gaitros
Database Systems Supertypes and Subtypes Lecture # 10.
Object Oriented Programming COP3330 / CGS5409.  Inheritance  Assignment 5.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MTech[IT],MPhil (Comp.Sci), MCA, MSc[IT], PGDCA, ADCA, Dc. Sc. & Engg.
INHERITANCE : Extending Classes. Rickshaw cart Bus Car Pulled Vehicles Inheritance Inheritance Vehicles Inheritance is the capability of one class of.
Object Oriented Programming: Inheritance Chapter 9.
CS1201: Programming Language 2 Classes and objects Inheritance By: Nouf Aljaffan Edited by : Nouf Almunyif.
AP Computer Science A – Healdsburg High School 1 Inheritance - What is inheritance? - “Is-a” vs. “Has-a” relationship - Programming example “CircleBug”
Inheritance and Subclasses CS 21a. 6/28/2004 Copyright 2004, by the authors of these slides, and Ateneo de Manila University. All rights reserved L16:
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
1 Inheritance Inheritance is a natural way to model the world in object-oriented programming. It is used when you have two types of objects where one is.
C Structs Programming in C++ Fall 2008 Dr. David A. Gaitros
1.  Inheritance Inheritance  Define a Class Hierarchy Define a Class Hierarchy  Visibility Mode Visibility Mode  Access Rights of Derived Classes.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Object Oriented Programming: Inheritance
Transport Homework Task
Table of Contents Class Objects.
Week 4 Object-Oriented Programming (1): Inheritance
Inheritance and Polymorphism
Understanding Inheritance
Chapter 10 Defining Classes. Chapter 10 Defining Classes.
Andy Wang Object Oriented Programming in C++ COP 3330
Learning Objectives Inheritance Virtual Function.
Michele Weigle - COMP 14 - Spr 04 Catie Welsh April 11, 2011
MSIS 670 Object-Oriented Software Engineering
Lecture 22 Inheritance Richard Gesick.
Arrays and Classes Programming in C++ Fall 2008
Amounts of Different Wastes in 100 kg of Trash
INFS 6225 Object Oriented Systems Analysis & Design
Code reuse through subtyping
SYS466 Domain Classes – Part 1.
| Website for students | VTU NOTES
CS1201: Programming Language 2
CS1201: Programming Language 2
C++ Inheritance.
Mind Moo-ver.
Early Readers (with audio)
Fundaments of Game Design
Adapter Design Pattern
By Rajanikanth B OOP Concepts By Rajanikanth B
Chapter 9 Inheritance.
Object Oriented Analysis and Design
B.FathimaMary Dept. of Commerce CA SJC Trichy-02
Object Oriented Design & Analysis
COP 3330 Object-oriented Programming in C++
Announcements Assignment 4 Due Today Lab 8 Due Wednesday
Inheritance in C++ Inheritance Protected Section
Presentation transcript:

Inheritance Basics Fall 2008 Dr. David A. Gaitros dgaitros@admin.fsu.edu

The Reason for Inheritance “Why write the same code twice?” This sums up the reason for inheritance quite nicely. Take the example of an employee database. There are many kinds of employees which have different attributes (data points) that need to be tracked for each one. However, there are some attributes that are common to ALL employees. This code should be written and “inherited” by those modules that handle the specifics for each type of employee.

Inheritance Examples of relationships A class called Geometric_Objects could derive classes like Circle, Square, and Line A class called Sport could derive classes like Football, Baseball, and Soccer A class called BankAccount could derive classes such as Checking, Savings, and Debit A class called vehicle could derive classes called Car, Train, Bus, Motorcycle, and Airplane We could use the Car class as a base class and derive other classes such as Ford, Toyota, Buick, Honda, etc.

Inheritance Declaring a Derived Class “When we say that some class D is a derived of some other class B, we are saying that class D has all of the features of class B but with some extra. Class B is called the base class. //class derivedclassname: public baseclassname // class Sport { …. } class Football: public Sport { …

Inheritance Layers of Inheritance class Vehicle { … } class Car: public Vehicle { … class Honda: public Car { …

Protection Levels public – Any member that is public can be directly accessed by name from anywhere. Poor practice to have data values with public access. private – Any member that is private can only be accessed directly only by the class in which it is declared. protected – Any member that is protected can be access directlry by the class in which it was declared and any classes that are derived.