Question: Multiple inheritance II. In this exercise, we again consider multiple inheri-tance. As in Exercise 4 we assume that each parent class B is inherited by
Multiple inheritance II. In this exercise, we again consider multiple inheri-tance. As in Exercise 4 we assume that each parent class B is inherited by the subclass A only once. For each non-first parent class B, the object organization in Exercise 4 stores a dedicated table tA,B for the virtual methods of class A that are visible in B. Thus, all methods from tA,B are also contained in tA. We want to eliminate this inefficiency. Our goal is to save a virtual method known to B only in the table tA,B and not in the tables tA and tA ,B for classes A between A and B. For this, the address environment for class A is modified such that A( f) returns a pair dt, i where dt is the relative address of the reference to the table t, and i is the index where the start address for f in t is recorded. Following the start address _ f, the table t memorizes the relative distance dt for recovering the A-view of the object. Relative to an A-view a to an object, we obtain the start address of the pair (_ f, dt) for the method f by: S[a + dt]+ 2 I (a) Modify the call to a virtual method according to this optimization. (b) Estimate the savings that this optimization offers. (c) Give an algorithm that computes, for a given class hierarchy, the distances dA,B, the address environment A for virtual functions of A, and constructs the required tables.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
