Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a class named 'cylinder' that inherits from the 'circle' and 'rectangle' classes. The 'cylinder' class must not have any member data. All member functions

image text in transcribed

Write a class named 'cylinder' that inherits from the 'circle' and 'rectangle' classes. The 'cylinder' class must not have any member data. All member functions of the 'cylinder' class will be located in the 'public' section. The member functions to be defined are explained below. I. The 'write size' function will take two real numbers (floats) as parameters. The first parameter should be the height of the cylinder and the second parameter should be the radius of the cylinder (r). ii. The 'find surface area' function will return the surface area of the cylinder. iii. The 'find volume' function will return the volume of the cylinder. (base area x height). iv. The '++' operator will increase the cylinder height by 1.

#include #include #define pi 3.14285 NMON 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 struct dims { float length, height; } class rectangle { private: float length, height; protected: dims getDim() { dims d; d.length = length; d.height = height; return(d); } float getArea(){ return (length * height); } void setDim(float len, float hei) { length = len; height = hei; = NN EHHHHH to co W NOCO GO WEB = 24 - mmmmmmmm 25 26 27 28 29 30 31 32 33 34 35 36 371 38 39 40 41 42 43 }; class circle { private: float rad; float getDim() { return(rad); } protected: float circumference(){ return (2*pi*rad); } float getArea() { return (pi*rad*rad); } float setDim(float r){ rad=r; } }; = 9

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

Step: 3

blur-text-image

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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions