Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider a graphics system that has classes for various figures rectangles, squares, triangles, circles and so on. For example, a rectangle might have data members

Consider a graphics system that has classes for various figures rectangles, squares, triangles, circles and so on. For example, a rectangle might have data members for 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. You are to implement such a system. The class Figure is the base class. You should add only Rectangle and Triangle classes derived from Figure. Each class has stubs for 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 do nothing more than output this message. The member function center calls the erase and only stubs for erase and draw, center will not do any centering but will call the member functions erase and draw. Also add an output message in the member function center that announces that center is being called. The member functions should take no arguments. There are three parts to this project: a. Write the class definitions using no virtual functions. Compile and test. b. Make the base class member functions virtual. Compile and test. c. Explain the difference in results. For a real example, you would have to replace the definition of each of these member functions with code to do the actualdrawing. You will be asked to do this is program 6. Use the following main function for all testing: //This program tests Programming project 5. #include #include figure.h #include rectangule.h #include triangle.h using std :: cout; int main() { Triangle tri; tri.draw( ); cout << Derived class Triangle object calling center ( ). ; tri.center ( ); //Calls draw and center Rectangle tect; rect.draw( ); cout << Derived class Rectangle object calling center (). ; rect.center ( ); //Class draw and center return 0; }

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

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions

Question

=+ Are ballots compulsory?

Answered: 1 week ago