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
Get step-by-step solutions from verified subject matter experts
