#include
class rectangle
{
private:
int l,br;
public:
rectangle()
{
l=br=0;
cout<<"\n\nConstructor with 0 Parameter is called";
}
rectangle(int a)
{
l=br=a;
cout<<"\n\nConstructor with 1 Parameter is called";
}
rectangle(int a ,int b)
{
l=a;br=b;
cout<<"\n\nConstructor with 2 Parameters is called";
}
int area()
{
return(l*br);}
};
int main()
{
clrscr();
rectangle r1;
rectangle r2(5);
rectangle r3(2,4);
cout<<"\n\nArea of First Rectangle="<
return 0;
}
/*********************************
OUTPUT
***********************************
Constructor with 0 Parameter is called
Constructor with 1 Parameter is called
Constructor with 2 Parameters is called
Area of First Rectangle=0
Area of Second Rectangle=25
Area of Third Rectangle=8
*/
No comments:
Post a Comment