I have this code:

void ShapeArr::publishStats()
{
	double ap = 0.0;

	for (int i=0; i < currCount; i++)
	{
		Shape *s = arr[i];
		ap += s->getAPRatio();
	}
	cout << "Max APRatio = " << [B]???[/B] << "	Average APRatio = " << ap/currCount << endl;
}

What do I need to do to actually calculate the MAX APRatio? "getAPRatio" is being called 3-4 times and returning a single integer each time. Of the 3 or 4 times it's called, I need to somehow compare them and take the biggest one as my max. I think the average is set correctly, but I'm not sure how to separate them and compare them to get the max. Any help??

Then I can't ;get the average though because "ap/currCount" won't work if ap is an array...??

Ok, I think I got it...:

double Max(const double *Numbers, const int Count)
{
	double Maximum = Numbers[0];

	for(int i = 0; i < Count; i++)
		if( Maximum < Numbers[i] )
			Maximum = Numbers[i];

	return Maximum;
}

void ShapeArr::publishStats()
{
	double ap = 0.0;
	double tempArr[5];
	double x = 0.0;
	for (int i=0; i < currCount; i++)
	{
		Shape *s = arr[i];
		ap = s->getAPRatio();
		x += s->getAPRatio();
		tempArr[i] = ap;
	}

	double Maximum = Max(tempArr, currCount);
	cout << "Max APRatio = " << Maximum << "	";
	cout << "	Average APRatio = " << x/currCount << endl;
}

Now in my add funcs, I declare new shapes from classes...How do i destruct them/free up the memory of those "new's"??

Post deleted, didn't check my internal delay to follow up on posts posted while I was writing mine.

Sounds good, but I still need help with how to delete the memory I allocated for all the shapes I called "NEW". I delete "arr" in the shapearr destructor, but how do I properly delete the memory I allocated by the new Rectangle, new Circle, new Triangle, and new RegularPoly in their respective add functions? HELP!?

This article has been dead for over six months. Start a new discussion instead.