Write a program to calculate the area of a rectangle by creating a class named 'Area'
with two variables ‘length’ and ‘breadth’ and two functions. First function named as
'setValues' set the length and breadth of the rectangle and the second function named as
'getArea' returns the area of the rectangle.
class Area {
public:
void setValue(double length, double breadth) {
this->m_length=length;
this->m_breadth=breadth;
}
double getArea() {
return m_length * m_breadth;
}
private:
double m_length;
double m_breadth;
};
Comments
Leave a comment