Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement base struct Shape and derived struct Circle, Rectangle and Square simulating polymorphism without using the virtual keyword. Do not use the C++ inheritance or

Implement base struct Shape and derived struct Circle, Rectangle and Square simulating polymorphism without using the virtual keyword. Do not use the C++ inheritance or polymorphism mechanisms but simulate them as described in our lecture. You are allowed to use some lecture code. Your code must be general. Use standard C++, such that the following main() works. You are not allowed to modify the main(). You are not allowed to include any files or built-in libraries, except for output. Submit your standard C++ code in the textbox below. Do not write the main() again.

int main() { Circle circle; CircleInitialize(&circle, 10); // circle with radius 10

Rectangle rectangle; RectangleInitialize(&rectangle, 3, 5); // rectangle with width 3 and height 5

Square square; SquareInitialize(&square, 7); // square with side length 7

Shape* shapes[3]; shapes[0]=(Shape*)&circle; shapes[1]=(Shape*)&rectangle; shapes[2]=(Shape*)

double total_area=0;

int i; for(i=0;i<3;i++) { double d=GetArea(shapes[i]); total_area+=d; } cout<

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

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions

Question

* Find i0 (t) for t > 0 in the circuit of Fig. 16.50. 2 1 1 F 0.5v

Answered: 1 week ago

Question

Elucidate the steps involved in quantification of variables.

Answered: 1 week ago

Question

3. Make sure to put the table in a new worksheet. Click OK

Answered: 1 week ago