Thursday, January 6, 2011

//Program to demostrate the functioning of constructors in C++

#include
#include
class rectangle
{
private:
int l,b;
public:
rectangle()
{
l=5,b=5;
}
int area()
{
return(l*b);
}};
int main()
{
clrscr();
rectangle r1;
cout<<"\nAREA OF RECTANGLE="<
getch();
return 0;
}
/*******************************
OUTPUT
*********************************

AREA OF RECTANGLE=25
*/

No comments:

Post a Comment

Programming the Whole World!