Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include "C:\MinGW\lib\gcc\mingw32\4.8.1\circleType.h"
- using namespace std;
- class Cylinder: public circleType {
- public:
- void print();
- void setRadiusBase(double r){
- if(r>=0){
- radius=r;
- }else{
- radius=0;
- }
- }
- double getRadius(){
- return radius;
- }
- double surfaceArea(){
- circleType t=circleType(radius);
- double area=t.Area();
- return area;
- }
- double volume(){
- double vol=surfaceArea()*height;
- return vol;
- }
- double setCenter(double x1,double y1){
- x=x1;
- y=y1;
- }
- Cylinder(double r = 0,double h=0){
- radius=r;
- height=h;
- }
- private:
- double radius;
- double height;
- double x,y;
- };
- int main(){
- double r,h;
- cout<<"Enter the radius of the base: ";
- cin>>r;
- cout<<"Enter the height of the cylinder: ";
- cin>>h;
- Cylinder x;
- x=Cylinder(r,h);
- double area=x.surfaceArea();
- cout<<"Surface area of cylinder: "<<area;<<endl;
- double vol=x.volume();
- cout<<"Volume of cylinder: "<<vol<<endl;
- }
- #ifndef CIRCLETYPE_H_INCLUDED
- #define CIRCLETYPE_H_INCLUDED
- class circleType
- {
- public:
- void print();
- void setRadius(double r){
- if(r>=0){
- radius=r;
- }else{
- radius=0;
- }
- }
- double getRadius(){
- return radius;
- }
- double Area(){
- double area=3.14*radius*radius;
- return area;
- }
- double circumference(){
- double circum=2*3.14*radius;
- return circum;
- }
- circleType(double r = 0){
- radius=r;
- }
- private:
- double radius;
- };
- #endif // CIRCLETYPE_H_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement