Question
My Programming Lab - C++ Consider a graphics system that has classes for various figures, say rectangles, squares, triangles, circles, and so on. For example,
My Programming Lab - 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 message telling 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started