Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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++

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Discuss the steps of a generic change project.

Answered: 1 week ago

Question

=+2 Why did OBI create Centers of Excellence?

Answered: 1 week ago