Ons the speed overhead resulng from the dynamic

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: of the virtual table (vtable): –  At compile .me, the constructor of an object containing virtual func.ons must ini.alize the virtual table, which is the table of pointers to its member func.ons. •  The speed overhead resul.ng from the dynamic binding process: –  At run .me, virtual func.ons are called using pointer indirec.on, which results in a few extra instruc.ons per method invoca.on as compared to a non ­virtual method invoca.on. •  Virtual func.ons whose resolu.on is only known at run ­.me cannot be inlined. Examples class Book{ public: virtual double shipping (); void update(int); ... } class AudioBook : public Book{ public: double shipping(); void update(double); ... } AudioBook b(...); Book a=b; //ok a.shipping(); //call ?, dynamic/static Book* ap=&b; ap->shipping(); //call ?, dynamic/static ap->update(1995); //call ?, dynamic/static Dynamic Binding Provides Abstrac.on and Facilitates Code Reuse •  W...
View Full Document

This document was uploaded on 03/06/2014 for the course CS 3710 at Memorial University.

Ask a homework question - tutors are online