class Rectangle // Class declaration
{
int width;
int length;
public:
// Default constructor
Rectangle()
{
width = 1;
length = 1;
}
// Parameterized constructor
Rectangle(int w, int l)
{
width = w;
length = l;
}
void SetValues() // Prompts the user to enter values
{
cout << "Enter the width;";
cin >> width;
cout << "Enter the length :";
cin >> length;
}
int GetWidth() const // The function is constant
{
return width;
}
int GetLength() const // The function is constant
{
return length;
}
int GetArea() // Sets the formula for area
{
return width*length;
}
int GetPerimeter() // Sets formula for perimeter
{
return width * 2 + length * 2;
}
};
Since you need to iterate through multiple objects, create an array of objects, and the step through the array calling the appropriate functions for each.
So where would this go? In main. I'm really having trouble so it would help if you can like explain it a little more in detail. (not trying to be rude) @mastakhan