write a class circle with one protected data member radius. Write three member function set radius to set radius value with parameter value area to display area and circum to calculate and display circumfance of circle
#include<iostream.h>
#include<stdlib.h>
using namespace std;
class Circle{
protected:
float radius;
};
class child : public Circle{
public:
void setRadius(float rad){
radius=rad;
}
void displayArea(){
float area=3.14*radius*radius;
cout<<"Area of circle"<<area<<endl;
}
void displayCircumference(){
float circum=2*3.14*radius;
cout<<"Circumference of Circle is = "<<circum<<endl;
}
};
int main(){
child obj;
obj.setRadius(5);
obj.displayArea();
obj.displayCircumference();
return 0;
}
Comments
Leave a comment