Funcon overloading compile me type resoluon stac

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: object that the func/on is invoked on (as explicit or implicit parameter), compiler can decide which func/on to call – sta/c binding. Book  ­Book();  ­Book(string, int);  ­Book(const Book&);  ­void update(string);  ­void update(int);  ­double shipping(); IS ­A AudioBook  ­AudioBook()  ­AudioBook(string, int, double)  ­AudioBook(const AudioBook&);  ­void update(double);  ­double shipping(); Polymorphism •  In programming languages, polymorphism refers to objects of different type are handled using the same interface (func/on). •  Func/on overloading: –  Compile /me type resolu/on (sta/c binding). •  Generic func/ons (parametric polymorphism): –  Compile /me type resolu/on (sta/c binding). •  Inheritance (subtype polymorphism): –  Compile /me type resolu/on( sta/c binding) –  Run ­/me type resolu/on (dynamic binding). 3 10/9/12 Dynamic Binding •  Dynamic binding: the choice of which of the overrideing func/ons to call is deferred un/l run /me. •  C++ implementa/on: –  Base class object pointer (*) can store derived class class pointer. AudioBook a(..); Book* bp=&a; •  The func/on for dynamic binding in the base class is declared as virtual; virtual double B...
View Full Document

Ask a homework question - tutors are online