Solution Must Include Header Implementation File Test Files C Write Code Consider Graphi Q11246305

.Your solution mustinclude header, implementation file, and test files.
InC++ write a code to Consider a graphics system that has classes forvarious figures rectangles, squares, triangles, circles, and so on.For example, a rectangle might have data members for Height, Widthand center point, while a square and circle might have only acenter point and an edge length or radius.

In a well-designed system, these would be derived from a commonclass, Figure.You are to implement such a system.
The class Figure is the base class. You should add onlyRectangle and Triangle classes derived from Figure.

Each class has two member functions erase

draw
Each of the member functions erase and draw outputs a message telling what function has been called and whatthe class of the calling object is. For example if you call thefunction erase from the object of type Rectangle, the outputis “this isthe function Rectangle::erase()”.(These functions do nothing more than output this message.)
The base class has another extra function named center.The member function center will also output a message likethis: “themember function center is called to erase anddraw”.Then it will calls the erase and draw functions to erase and drawthe figure. So basically this function just write a line in theoutput and then it will call erase and draw functions.
All the member functions should take no arguments.
There are three parts to this project:

Write the class definitions using no virtual functions. Compile andtest. Make the base class member functions virtual. Compile and test.
Explain the difference in results .

Use the following main function for all testing(Rememberto include necessary files before main):

intmain() {

Triangletri;
tri.draw();
cout << “n In main, Derived class Triangle objectcalling”

<<” center().n”; tri.center();

Rectanglerect;
rect.draw();
cout << “n In main, Derived class Rectangle objectcalling”

<<” center().n”; rect.center();

return0; }

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.