Inheritance and Big O And your first reading assignment

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

Stacks and Queues & Inheritance 2014 Spring CS32 Discussion Jungseock Joo.
Ch 13. Features Found Only in Java Timothy Budd Oregon State University.
12/08/08MET CS Fall Polymorphism 10. Polymorphism Goal: Goal: Create methods that can be invoked with all object types, base as well as.
Virtual Functions Junaed Sattar November 10, 2008 Lecture 10.
Shallow Versus Deep Copy and Pointers Shallow copy: when two or more pointers of the same types point to the same memory – They point to the same data.
C++ facts From What all is inherited from parent class in C++? Following are the things which a derived class inherits from its.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 13: Pointers, Classes, Virtual Functions, and Abstract Classes.
1 Virtual Functions and Polymorphism Chapter What You Will Learn What is polymorphism? How to declare and use virtual functions for abstract classes.
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.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Taken from slides of Starting Out with C++ Early Objects Seventh Edition.
Chapter 15 – Inheritance, Virtual Functions, and Polymorphism
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 14: Pointers, Classes, Virtual Functions, and Abstract Classes.
Polymorphism. Introduction ‘one name multiple forms’ Implemented using overloaded functions and operators Early binding or static binding or static linking.
1 Chapter 10: Data Abstraction and Object Orientation Aaron Bloomfield CS 415 Fall 2005.
Object Oriented Programming with C++/ Session 6 / 1 of 44 Multiple Inheritance and Polymorphism Session 6.
Unit IV Unit IV: Virtual functions concepts, Abstracts classes & pure virtual functions. Virtual base classes, Friend functions, Static functions, Assignment.
OOP and Dynamic Method Binding Chapter 9. Object Oriented Programming Skipping most of this chapter Focus on 9.4, Dynamic method binding – Polymorphism.
Polymorphism and Virtual Functions. Topics Polymorphism Virtual Functions Pure Virtual Functions Abstract Base Classes Virtual Destructors V-Tables Run.
Copyright 2006 Oxford Consulting, Ltd1 February Polymorphism Polymorphism Polymorphism is a major strength of an object centered paradigm Same.
CS212: Object Oriented Analysis and Design Lecture 17: Virtual Functions.
OOP using C Abstract data types How to accomplish the task??? Requirements Details Input, output, process Specify each task in terms of input.
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.
CS212: Object Oriented Analysis and Design Lecture 16: Runtime Polymorphism.
Recap Introduction to Inheritance Inheritance in C++ IS-A Relationship Polymorphism in Inheritance Classes in Inheritance Visibility Rules Constructor.
Inheritance in C++ Bryce Boe 2012/08/28 CS32, Summer 2012 B.
Polymorphism and Virtual Functions One name many shapes behaviour Unit - 07.
CSC241 Object-Oriented Programming (OOP) Lecture No. 17.
A First Book of C++ Chapter 12 Extending Your Classes.
Abstract classes only used as base class from which other classes can be inherit cannot be used to instantiate any objects are incomplete Classes that.
Object Oriented Programming Some Interesting Genes.
@ George Wolberg, CSC212 Data Structure Lecture 6 Dynamic Classes and the Law of the Big Three Instructor: George Wolberg Department of Computer.
Design issues for Object-Oriented Languages
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Modern Programming Tools And Techniques-I
CS 215 Final Review Ismail abumuhfouz Fall 2014.
Chapter 13: Pointers, Classes, Virtual Functions, and Abstract Classes
7. Inheritance and Polymorphism
Andy Wang Object Oriented Programming in C++ COP 3330
Inheritance But first, a few homework corrections and clarifications
Class A { public : Int x; A()
Object-Oriented Programming & Design Lecture 18 Martin van Bommel
Object-Oriented Programming
Inheritance and Run time Polymorphism
CS212: Object Oriented Analysis and Design
Advanced C++ Topics Chapter 8.
Inheritance, Polymorphism and the Object Memory Model
Interfaces and Inheritance
Object Oriented Programming
Polymorphism Lec
Chapter 12: Pointers, Classes, Virtual Functions, and Abstract Classes
Inheritance, Polymorphism, and Virtual Functions
Inheritance Virtual Functions, Dynamic Binding, and Polymorphism
Polymorphism Polymorphism
“Under the Hood” of Polymorphism
9: POLYMORPHISM Programming Technique II (SCSJ1023) Jumail Bin Taliba
Pointers Dr. Bhargavi Goswami Department of Computer Science
Polymorphism Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition, by Kernighan.
Jeff West - Quiz Section 12
Inheritance Virtual Functions, Dynamic Binding, and Polymorphism
Chapter 8: Class Relationships
Today’s Objectives 10-Jul-2006 Announcements Quiz #3
Inheritance and Polymorphism
VIRTUAL FUNCTIONS RITIKA SHARMA.
CIS 199 Final Review.
COP 3330 Object-oriented Programming in C++
Jim Fawcett CSE687 – Object Oriented Design Spring 2014
C++ Polymorphism Reference and pointer implicit type casting
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 and Big O And your first reading assignment And any questions about the current homework assignment

Reading assignment For next Monday (Sept 18), you should read Chapter 10 as well as any other sections listed in the “prerequisites” that you need to understand chapter 10 There will be a quiz on this material, covering key ideas and concepts

Homework 1 Your first homework assignment is due by the end of the day on Wednesday Any last-minute questions?

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)

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) The actual function executed from a function call depends on the types involved in that function call

Dynamic dispatch: how?? If a class has at least one virtual function, it will have a vtable Each instance of a class with a virtual method will have a pointer to the vtable stored inside of it When a virtual function is called, the vtable pointer is checked The vtable associates a specific function implementation with each virtual function that the object has Based on the value in the vtable, the appropriate function is called

Pure virtual function: A virtual function with explicitly no implementation

Abstract class: A class with at least one pure virtual member function

Abstract class: A class with at least one pure virtual member function

Pure abstract class: A class with only pure virtual member functions

Constructors and Destructors Constructors are run from the top down in the inheritance heirarchy Destructors are run from the bottom up If you use inheritance or have any virtual methods, you always should have a virtual destructor

Inheritance Inheritance is a powerful way to use abstraction to reduce complexity We will be using inheritance (usually in the form of pure abstract classes) throughout this class Any questions?

Measuring performance: Big O notation Big O notation is used to describe the runtime performance of algorithms as the problem size changes Often care about either the amount of time taken, or the amount of memory used (or both) Let's take a look at how we can figure out what the big O value is…

Biggest item algorithm int largest(int data[], int n) Takes in an array and a size Returns largest item in the array Can safely assume array has at least one item