Write a program to use parameter constructor


 

/* Write a program to use  parameter constructor*/

#include<iostream.h>

#include<conio.h>

class rectangle

{

int length,breath;

public:

rectangle(int a,int b)

{

length=a;

breath=b;

}

void area()

{

int ar;

ar=length*breath;

cout<<“area of rectangle=”<<ar;

}};

void main()

{

clrscr();

rectangle r1(4,5);

r1.area();

getch();

}

ouput:

area of rectangle=20

Related Posts

Comments are closed.