Answer to Question #261291 in C++ for AB Agha

Question #261291

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.

1
Expert's answer
2021-11-04T16:25:54-0400
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;
};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS