Question: c++ Consider a graphics system that has classes for various figures, say rectangles, squares, triangles, circles, and so on. For example, a rectangle might have

c++

Consider a graphics system that has classes for various figures, say rectangles, squares, triangles, circles, and so on. For example, a rectangle might have data members height, width, and center point, while a square and circle might have only a center point and an edge length or radius, respectively. In a well-designed system, these would be derived from a common class, Figure. It is your job to implement this system. First, implement the base class Figure. Then, implement two classes that are derived from Figure - Rectangle and Triangle. Each class should have stubs for the member functions erase() and draw(). Each of these member functions outputs a messagetelling what function has been called and what the class of the calling object is. Since these are just stubs, they should do nothing more than output the message. Also implement the member function center(). Typically, center() would call erase and draw to erase and redraw the figure at the center. However, since our functions are only stubs, center() will simply print a message saying that center() has been called from the respective class. It will then call erase() and draw(), which will each print out their own message. You should implement the base class functions as virtual functions. Finally, test your program in main() by creating a Triangle object and a Rectangle object and calling draw(), erase(), and center() on each object.

c++ Consider a graphics system that has classes for various figures, say

SAMPLE RUN #0: . /Figures Interactive Session Hide Invisibles Show Highlighted Highlight: None Only Triangle object.called.draw function.... Triangle object.called erase.function.... Derived Triangle.object.calling.center). Triangle object.called.center function.... Triangle object.called erase.function.... Triangle.object.called.draw.function... Rectangle object.called draw-function... Rectangle object.called.erase.function... Derived-class-Rectangle . object-calling. center() .* Rectangle object.called.center function.... Rectangle object.called erase.function.... Rectangle-object.called-draw-function

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!