Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

}; }; Show the layout of objects of class E and the contents of the virtual func

ID: 3586683 • Letter: #

Question

};

};

Show the layout of objects of class E and the contents of the virtual function tables (you can ignore the this-offsets). What are the values assigned to variables i, j, k, and l when the following code is executed?

4. (25 pts) Given the following C++ class declarations class B { private: int x; public: virtual int foo)return this->bar); ) virtual int bar() 1 return 1; 1 class C f private: int x; public: virtual int foo) return 2; } class D : public B, public C private: int y; public: virtual int foo)return B::foo(): class E : public D i private: int z public: virtual int bar() f return 3; > Show the layout of objects of class E and the contents of the virtual function tables (you can ignore the this-offsets). What are the values assigned to variables i, j, k, and 1 when the following code is executed? B* p new D); C * g = new D(); B * r -new E); c * s new E(); int i = p->bar(); int j = g->foo( ) ; int k = r->bar(); int 1 s->foo();

Explanation / Answer

//values assigned to i,j,k,l are

i:1 //from class B bar()
j:1   //from class B f00()
k:3 //from class E bar()
l:3 //from Class B,C