1. ## Rectangle class

I have to implement a complete class called Rectangle with 5 methods: Constructor, Show, Area, Merge and TotalArea.
I've done Constructor, Show, Area and Merge methods, but I stuck in TotalArea function. In this function, it takes an array of rectangle as a parameter. This method returns the sum of the areas of the rectangle in the array.

and this is my source code, the first is rectangle.h, and the second is rectangle.cpp

Code:
```//rectangle.h
#include <string.h>
#include <stdlib.h>
#include <cstdlib>

class Rectangle
{
public:
Rectangle(double x, double y);

~Rectangle() {};
private:
double len;
double wid;

public:
void Show(void);
int Area(void);
Rectangle Merge(Rectangle r);
void TotalArea(void);
};```
Code:
```//rectangle.cpp
#include <cstdlib>
#include <iostream>
#include "rectangle.h"

using namespace std;
Rectangle::Rectangle(double x, double y)
{
len=x;
wid=y;
}
void Rectangle::Show(void)
{
cout<<"Leghth: "<<len <<"Width: "<<wid<<endl;
}

int Rectangle::Area(void)
{
double area;
area=len*wid;

}
Rectangle Rectangle::Merge(Rectangle r)
{
Rectangle d1(0.0,0.0);
d1.len=len+r.len;
d1.wid=wid+r.wid;
return d1;

};

int main(int argc, char *argv[])
{
Rectangle r1(2.0, 3.0);
Rectangle r2(7.0, 5.0);
Rectangle r3(1.0, 1.0);

r1.Show();

cout <<"Area of r2: "<<r2.Area()<<endl;
r3=r1.Merge(r2);
r3.Show();
/*
Retangle allRects[2];
allRects[0]=r1;
allRects[1]=r2;
cout<<"Total Area: "<<r2.TotalArea(allRects)<<endl;
*/
system("PAUSE");
return EXIT_SUCCESS;
}```

2. In this function, it takes an array of rectangle as a parameter. This method returns the sum of the areas of the rectangle in the array.
It can't take an array alone since you won't know how large the array is (you just get the pointer to the first item in the array). Therefore you must also pass the count of items in the array (or another pointer showing the end of the range).

Code:
`double TotalArea(const Rectangle* rect_array, int count) const;`
It is strange design, though: why would one need a Rectangle instance to be able to sum the areas of a bunch of completely unrelated Rectangles? A free function would be just fine.

You could post what you have tried, though. Also note that the current Area function is buggy, and the result should be double, if the rectangle works with doubles.