Question
Use three classes, Point. Circle, and Cylinder. Use inheritance property in derived classes; Circle and Cylinder. Use both constructors and setdata() functions to assign data
Use three classes, Point. Circle, and Cylinder. Use inheritance property in derived classes; Circle and Cylinder. Use both constructors and setdata() functions to assign data to objects. The Cylinder class should calculate volume and area of Cylinder by inheriting Area from circle class.
This program is written in c++. Please help me complete program. I can't figure out the issues. I need to use printdata() as well to print the radius, height, area, and volume in the main program.
#include
class point{
private: int x; int y;
public:
point(int _x, int _y){ x=_x; y=_y; } point() {} void setdata(int _x,int _y){ cin>>x; cin>>y; } };
class circle:public point {
private: int radius;
public:
circle(int _radius, int _x, int _y):point(_x, _y){ radius=_radius;
} void setdata(int _radius, int _x, int _y){ _radius=_x; } void printdata(int _radius, int _x, int _y){ cout<<"Radius ="<<" "<<_x< class cylinder: public circle{ private: int height; public: cylinder(int _height, int _radius, int _x, int _y):circle(_radius,_x,_y){ height=_height; } void setdata(int _height, int _radius, int _x, int _y){ _height=_y; } void printdata(int _height, int _radius, int _x, int _y){ cout<<"Area ="<<(2*3.14*_x*_y)+(2*3.14*_x*_x)< int main(){ }
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