Professional Documents
Culture Documents
23dcs056 (Prac5) PDF
23dcs056 (Prac5) PDF
:23DCS056
Information Technology
Practical List
1
Object Oriented Programming with C++ [CE144] Enrolment No.:23DCS056
PROGRAM CODE:
#include <iostream>
#include <cstdio>
#include <math.h>
class circle{
private:
float radius;
float pi=2*acos(0);
float area;
public:
circle(){
radius=1;}
circle(float r1){
radius=r1;}
~circle(){
}
2
Object Oriented Programming with C++ [CE144] Enrolment No.:23DCS056
void areacalc(){
area=pi*radius*radius;
cout<<"the area of radius "<<radius<<" is "<<area<<endl;
};
int main(){
class circle *c1;
c1= new circle();
c1->areacalc();
int count=1;
class circle *c2;
float radius;
cout<<"enter the radius for parameter constructor";
cin>>radius;
c2= new circle(radius);
count++;
c2->areacalc();
class circle *c3;
count++;
c3= new circle(*c1);
c3->areacalc();
for(int i=0;i<3;i++){
cout<<"one object is deleted"<<endl;
count--;
cout<<"total active objects are "<<count<<endl;
3
Object Oriented Programming with C++ [CE144] Enrolment No.:23DCS056
}
cout<<"23dcs056_vansh_malani"<<endl;
OUTPUT:
CONCLUSION:
This program helped us understand the three types of constructors: parameterised, default
and copy. it also helped us understand constructor overloading in c++ in objective
programming