

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The third homework assignment for cs 325 course. It covers various topics including thread safety, polymorphism, overriding, overloading, virtual destructors, and virtual pointer table. Students are required to answer detailed questions on these topics.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Homework # CS 325 Due: 9:30 am on Tuesday 17-Feb
Answer the following questions in detail:
More than one thread can correctly run the function simultaneously – thus no locking, racing, etc.
Consider the following declarations:
virtual void B0::basicFunction() void Y::basicFunction() virtual void X::basicFunction() void W::basicFunction()
then describe the polymorphic behavior of the pointers:
B0 *b0_ptr; Y *y_ptr; X *x_ptr; W *w_ptr;
Overriding a member function replaces a function with the same name through inheritance: the most recent inherited class may redefine a member function with the same name.
Overloading a function allows several functions with different signatures to have the same name.
Destructors are always invoked in the opposite order of the constructors. Thus, making a destructor virtual ensures the destructor associated with the pointer is
invoked which in turn invokes the rest of the destructors in the inverse order as the constructors.
Each class with a virtual member function (or inheriting virtually) has a virtual pointer table v_ptr. Thus all classes that inherit from a class with a v_ptr table access this table. More later…