CSE 130 Lecture Notes - Lecture 13: Virtual Method Table, Multiple Inheritance, Covariance

52 views4 pages

Document Summary

Int b; void g(int) int a int b. Assume f(int) { this. h(55+x); int a int b int c pc vptr int a int b int c. //compiles to ( * (this vptr[2]))(this, 55+x) C * pc; pc g(2); compiles to ( * (pc vptr[1]) ) (pc, 2) When functions are redefined , their suffixes are their the class names of where they are redefined! Don"t have to lookup in the vtable! (just a direct call) Have to look things up in the vtable! | int b | ( * ( pa vptr[0]))(pa) We"re not paying extra for pointers to virtual functions! A* pa = new b(); pa f(); B* pb = new b(); pb f(); Smalltalk and js have no static type system! In c++, compiler knows the superclass for obj. Invoke function ptr at fixed offset in vtable! If interface a contains all of interface b, then a

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