area of Circle

24 Jul

#include <iostream>

using namespace std;

class Circle{
        double radius, area;
        Circle(double r){
            radius = r;
        void setRadius(double r);
        double getRadius();
        double AreaOfCircle();


class Cylinder: public Circle{
        double height;
        Cylinder(double r,double h);
        double SArea();
        double Volume();
        void details();

void Circle::setRadius(double r){
    radius = r;
double Circle::getRadius(){
    return radius;
double Circle::AreaOfCircle(){
    area = 3.142 * radius * radius;
    return area;
Cylinder::Cylinder(double r,double h) : Circle(r){
    height = h;
double Cylinder::SArea(){
    double surface_area = 3.142 * 2 * getRadius()* height + AreaOfCircle();
    return surface_area;
double Cylinder::Volume(){
    double volume = AreaOfCircle() * height;
    return volume;
void Cylinder::details(){
    cout<<"Cylinder details: "<<endl;
    cout<<"Radius: "<<getRadius()<<endl;
    cout<<"Height: "<<height<<endl;
    cout<<"Area of circle: "<<AreaOfCircle()<<endl;
    cout<<"Surface Area: "<<SArea()<<endl;
    cout<<"Volume: "<<Volume()<<endl;

int main()
    Cylinder one(7, 10);
    return 0;

Leave a comment

Posted by on July 24, 2012 in C++


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: