C++ language

adplus-dvertising
A Program Of Class With Two Objects
Previous Home Next
#<iostream.h>
class reactangle
{
int a, b; // private by default
public :
void set_values(int,int);
int area()
{		
return(a*b);
}
};
void rectangle::set_values(int a,int b)
{
x=a;
y=b;
}
int main()
{
rectangle rect,rectb;
rect.set_values(3,4);
rect.set_value(5,7)
cout<<"rect area"<<rect.area();
cout<<"rectb area"<<rectb.area();
return0;
}
Output: rect area 12 rectb area 35
Previous Home Next