Inheritance But first, a few homework corrections and clarifications

Slides:



Advertisements
Similar presentations
OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
Advertisements

METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
Written by: Dr. JJ Shepherd
C12, Polymorphism “many forms” (greek: poly = many, morphos = form)
 In inheritance the child (subclass) chooses its parent (superclass)  Remember - only public or “protected” methods and variables are inherited  Should.
ECE122 L22: Polymorphism Using Inheritance April 26, 2007 ECE 122 Engineering Problem Solving with Java Lecture 22 Polymorphism using Inheritance.
Inheritance and Polymorphism Recitation – 10/(16,17)/2008 CS 180 Department of Computer Science, Purdue University.
CPSC150 Interfaces Chapter CPSC150 Inheritance Review No different than any other class. Has no access to or information about subclasses class.
Static and Dynamic Behavior Fall 2005 OOPD John Anthony.
Abstract Classes and Interfaces
Abstraction: Polymorphism, pt. 1 Abstracting Objects.
Chapter 15 – Inheritance, Virtual Functions, and Polymorphism
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
Object-oriented programming: C++ class A { private: …… // can be accessd by A protected: …… // can be accessed by A and // its derived classes public:
OOP and Dynamic Method Binding Chapter 9. Object Oriented Programming Skipping most of this chapter Focus on 9.4, Dynamic method binding – Polymorphism.
Inheritance - Polymorphism ITI 1121 Nour El Kadri.
RIT Computer Science Dept. Goals l Inheritance l Modifiers: private, public, protected l Polymorphism.
1 COMP313A Programming Languages Object Oriented Progamming Languages (3)
C# F 1 CSC 298 Object Oriented Programming (Part 1)
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
Chapter 10 Inheritance and Polymorphism
Abstract Classes. Review PA – 3 Design Considerations /Web/CS239/programs/pa3/draft.php ?harrisnlCS239
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
1 COSC2007 Data Structures II Chapter 9 Class Relationships.
ISBN Object-Oriented Programming Chapter Chapter
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
Peyman Dodangeh Sharif University of Technology Fall 2014.
CSI 3125, Preliminaries, page 1 Inheritance. CSI 3125, Preliminaries, page 2 Inheritance Using inheritance, can create a general class that defines traits.
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 Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
Lecture 12 Implementation Issues with Polymorphism.
Lecture 10 – Polymorphism Nancy Harris with additional slides Professor Adams from Lewis & Bernstein.
Inheritance a subclass extends the functionality of a superclass a subclass inherits all the functionality of a superclass don't reinvent the wheel – "stand.
Review for Test2. Scope 8 problems, 60 points. 1 Bonus problem (5 points) Coverage: – Test 1 coverage – Exception Handling, Switch Statement – Array of.
Data Structures and Algorithms in JAVA Chapter 2.
Design issues for Object-Oriented Languages
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Polymorphism in Methods
Modern Programming Tools And Techniques-I
OBJECT ORIENTED PROGRAMMING
Polymorphism.
Inheritance ITI1121 Nour El Kadri.
Advanced Programming in Java
Scope and Code Generation
Inheritance and Big O And your first reading assignment
Inheritance and Polymorphism
Inheritance and Encapsulation
Class A { public : Int x; A()
Inheritance and Run time Polymorphism
Programming Language Concepts (CIS 635)
12 Data abstraction Packages and encapsulation
Object Oriented Programming
Object Oriented Analysis and Design
OOP’S Concepts in C#.Net
Inheritance, Polymorphism, and Interfaces. Oh My
CSC 143 Inheritance.
Polymorphism CT1513.
Polymorphism Polymorphism - Greek for “many forms”
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Inheritance.
Chapter 9 Carrano Chapter 10 Small Java
Inheritance and Polymorphism
CIS 199 Final Review.
Agenda Inheritance Polymorphism Type compatibility Homework.
Chapter 11 Inheritance and Encapsulation and Polymorphism
Advanced Programming in Java
Lecture 6: Polymorphism
CIS 110: Introduction to computer programming
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.
Presentation transcript:

Inheritance But first, a few homework corrections and clarifications Oh, and a bit of recursion

Corrections Classes are cancelled next Wednesday for LeAD day and the Mass of the Holy Spirit Since there won’t be any class, there’s no point having the assignment due by the start of class The assignment is now due September 13 at 11:59pm.

FAQs Do I need to change functions like addFront and popFront? Those functions have no loops, so no changes are needed Am I guaranteed to get full credit if main.cpp runs correctly? NO. There are some possible bugs that main.cpp won’t detect. Consider what happens when the list is very small… Should I use global variables to get information from one function to another? Short answer: no Long answer: noooooooooooooooooooooo

Recursion int itemCountUntilNegative(int arr[]) Let's say we wanted to write a recursive function that takes in an array and returns the number of elements in the array until a negative element occurs

Inheritance Inheritance allows you to take an existing class and add onto what is done in it Let's start with an example, and then talk about what's going on

Vocab Subclass Superclass Inheritance hierarchy Base class Child class Parent class Inheritance hierarchy Base class

Initializer list

Access modifiers public: protected: private: Everyone can read and write these variables, and call these functions protected: This class and all subclasses can read and write variables, and call functions private: Only this class, not subclasses, can read/write variables, call functions

Static Dispatch When a function is called, the specific implementation to be used is determined at compile time

or virtual void react() override {

Dynamic dispatch The specific function implementation to use for a function call is resolved at run time Polymorphism: "In programming languages and type theory, polymorphism (from Greek πολύς, polys, "many, much" and μορφή, morphē, "form, shape") is the provision of a single interface to entities of different types.[1] A polymorphic type is one whose operations can also be applied to values of some other type, or types.[2]" (Thank you, Wikipedia)