//Client code is the code that USES Rectangle objects
#include "Rectangle.h"

// pass a ptr to a Rectangle 
double  pagesize(Rectangle *r)
{
// multiply the length and the width of the object r is pting to
return r->length * r->width;

// r->getLength() * r->getWidth()  // if they are private
} 

int main()
{

Rectangle rectarr[10]; // array of 10 rectangles
Rectangle *rectptr;
Rectangle box(10,12);

rectptr = &box;
cout << "length of box is: " << rectptr->length << " or: " << 
	(*rectptr).length << endl;

box.setLength(300);
rectarr[0]=box;
rectptr=rectarr;  // name of the array is assigned to Rectangle ptr 

cout << "first array elt length is: " << rectptr->getLength() << endl;

// dynamic memory allocation of an array of Rectangles
rectptr = new Rectangle[12];

// you can use rectptr as a regular array name
rectptr[1].setLength(43); // same *(rectptr+1).setLength(43)
rectptr[1].setWidth(43);
cout << "length of loc 1 of array is: " << rectptr[1].length << endl;

rectptr->setLength(8);  // set the length of 0th elt 
rectptr->setWidth(8);  // set the length of 0th elt 
cout << "length of loc 0 of array is: " << rectptr[0].length << endl;

// this is a reminder that dereferencing the address of the array
// gives the 0th element
int arr[10];
*arr = 5;  // arr[0]     

// delete the dynamic array
delete [] rectptr;

// dynamic memory allocation of an object with params to constructor

Rectangle *ptrbox = new Rectangle(50,60);

cout << "length of new box is: " <<       ptrbox->getLength() << endl;

// call pagesize passing the address of box
cout << "area of box is: " << pagesize(&box) << endl;

return 0;
}
