Santa Monica College CS 20A: Data Structures with C++ Midterm Spring 2018 Name 3
ID: 3701496 • Letter: S
Question
Santa Monica College CS 20A: Data Structures with C++ Midterm Spring 2018 Name 32. a. Suppose have we a class that inherits from Thing called Mabob with definition as follows: class Mabob : public Thing public: Mabob (int x, int y) :Thing (x,y) f q new int (y) -Mabob) delete qi) void print) f Thing: :print void majig) ( intt new int (2()) delete q qt; private: int *qi Assuming we have all the changes you've made in previous problem. What other changes o Thing should we make in order to use polymorphism? For example: Thing *mb - new Mabob (2, 3) mb->print ); delete mb;Explanation / Answer
Please post Thing class to get answer of all:
a. we need to make print() method virtual in Thing class.
b. We care calling Thing::print() method, utilizing the super calss method in subclass , means subclass gets all methods from super calss.
c. SInce you have not posted Thing class so, we can not answer this question,