Use of object pointer in c++

Use of object pointer-1 in c++
code:
#include<iostream>
using namespace std;
class Area{
    double height,radious;
public:
    Area(){
    radious=0;
    height=0;
    }
    Area(double height,double radious){
    this->height=height;
    this->radious=radious;
    }
    ~Area(){
    cout<<"Object are distroyed."<<endl;
    }
    void set(double h,double r){
    height=h;
    radious=r;
    }
    double CalCulate();
};
double Area::CalCulate(){
    if(height>1){
        return 3.1416*radious*radious*height;
    }
    else{
        return 3.1416*radious*radious;
    }
}
int main()
{
    Area *ob;
    ob=new Area(2,3);//dynamically allocate in c++.
    cout<<ob->CalCulate()<<endl;
    ob->set(2.9 ,3.8);
    cout<<ob->CalCulate()<<endl;
    return 0;
}



মন্তব্যসমূহ

এই ব্লগটি থেকে জনপ্রিয় পোস্টগুলি

Big Big mod

শিরোনামহীন গল্প

Dictionaries and Maps