fork download
  1. #include <iostream>
  2. using namespace std; // consider removing this line in serious projects
  3.  
  4. class Rectangle{
  5. private:
  6. double width;
  7. double length;
  8. public:
  9. void setWidth(double);
  10. void setLen(double);
  11.  
  12. double getWidth() const;
  13. double getLen() const;
  14. double getArea() const;
  15. };
  16.  
  17. void Rectangle::setWidth(double x){
  18. width = x;
  19. }
  20.  
  21. void Rectangle::setLen(double y){
  22. length = y;
  23. }
  24.  
  25. double Rectangle::getWidth() const{
  26. return width;
  27. }
  28.  
  29. double Rectangle::getLen() const{
  30. return length;
  31. }
  32.  
  33. double Rectangle::getArea() const{
  34. return length * width;
  35. }
  36.  
  37. int main() {
  38. Rectangle bruh;
  39.  
  40. bruh.setLen(2);
  41. bruh.setWidth(1.5);
  42.  
  43. cout << "The area of your rectangl is: " << bruh.getArea();
  44. cout << endl;
  45.  
  46. }
Success #stdin #stdout 0s 5204KB
stdin
Standard input is empty
stdout
The area of your rectangl is: 3