Question: y D Microsoft Word-Assignment Jian C O file:///Users/JasonDownloads/Assignment%208.pdf ::?? ???? -- 0750 1???? ?????????.. Computer Science G Learn HTML: Eleme...-3 waschools Online.. w C++

 y D Microsoft Word-Assignment \ Jian C O file:///Users/JasonDownloads/Assignment%208.pdf ::?? ????

y D Microsoft Word-Assignment \ Jian C O file:///Users/JasonDownloads/Assignment%208.pdf ::?? ???? -- 0750 1???? ?????????.. Computer Science G Learn HTML: Eleme...-3 waschools Online.. w C++ Language-C- C++ Environment S . ]???? >> CSCI200A-Assignment Assignment 8 Q1. Create a simple "shape" hierarchy: a base class called Shape and derived classes called Circle, Square, and Triangle. In the base class, make a virtual function called draw(),and override this in the derived classes. Make an array of pointers to Shape objects that you create on the heap (and thus perform upcasting of the pointers), and call draw() through the base-class pointers, to verify the behavior of the virtual function Q2. Modify Q1 so draw()is a pure virtual function. Try creating an object of type Shape. Try to call the pure virtual function inside the constructor and see what happens. Leaving it as a pure virtual, give draw() a definition. Q3. Expanding on Q2, create a function that takes a Shape object by value and try to upcast a derived object in as an argument. See what happens. Fix the function by taking a reference to the Shape object. The source code should be named Q1.cpp, Q2.cpp, and Q3.cpp and submitted to C4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!