CS 2150 Lecture Notes - Lecture 18: Dynamic Dispatch, Multiple Inheritance, Virtual Function

52 views3 pages

Document Summary

Protected: only myself and subclasses can access it: class contact: public name, any object of type contact has everything that name has. We have a sphere that wants to be a shape but also wants it to be a comparable. We want sphere to inherit from shape (you can pass a subclass for a superclass) Java is a single inheritance language; sphere would only inherit from shape. Because they implement serializable, they must have implementation for those functions. Lecture 18: c++ inheritance: specifies hierarchical relationship between types. Java, everything is a subclass of object i: subclasses can not access private. Issue when you call just the method, for example foo(). Static vs dynamic dispatch vii: dispatch: invoking a subroutine. Java can fake multiple inheritance through interfaces, it"s actually allowing type substitution for multiple classes that implement the interface: compiler generally encounters static dispatch rather than dynamic ix.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents