my compiler keeps saying that i have an operator error at lines 22 and 50. what did i do wrong??? plz help

#include <iostream>
using namespace std;

class Rectangle
{
public:
	Rectangle()/*rectangle constructor defaults the values for length, width,  area, and perimeter to 1 and initializes five rectangle objects to zero*/
	{
		rectangleLength = rectangleWidth = 1;
		rPerimeter = rArea = 1;
		for ( int r = 1; r <= 5; r++)
			rArray[r] = 0;

	}

void setRectangleLength()// set length value between 1 to 20
{
	bool lengthTest = false;
	
	while ( !lengthTest )
	{
		cout << "\nEnter the length of the rectangle " << lengthc() << "from 1 to 20: ";
		cin >> rectangleLength;
		
		if ( rectangleLength < 0 || rectangleLength > 20 )
		{
			cout << "The value " << rectangleLength << " is out of range.\n";
			cout << "Try again.\n";
			lengthTest = false;
		}
		else
		{
			lengthTest = true;
		}
		
	}
}

int getRectangleLength()
{
	return rectangleLength;
}

void setRectangleWidth()// set width value between 1 to 20
{
	bool widthTest = false;
	
	while ( !widthTest )
	{
		cout << "\nEnter the width of the rectangle " << widthc() << " from 1 to 20: ";
		cin >> rectangleWidth;
		
		if ( rectangleWidth < 0 || rectangleWidth > 20 )
		{
			cout << "The value " << rectangleWidth << " is out of range.\n";
			cout << "Try again.\n";
			widthTest = false;
		}
		else
		{
			widthTest = true;
		}
		
	}
}

int getRectangleWidth()
{
	return rectangleWidth;
}


void calculatePerimeter()
{
	rPerimeter = 2 * (getRectangleLength() + getRectangleWidth());
	cout << "The perimeter of the rectangle is: " << rPerimeter << endl;

}

void calculateArea()
{
	rArea = getRectangleLength() * getRectangleWidth();
	cout << "The area of the rectangle is: " << rArea << endl;

}

void setDrawRectangle()
{
	char border;
	char fill;
	cout << "Enter the character you would like to see as the border of the rectangle:";
	cin >> border;
	cout << "Enter the symbol to fill the rectangle:";
	cin >> fill;		
}

char getDrawRectangle()
{
	return (border, fill);
}

void draw()
{
	setDrawRectangle();
	getDrawRectangle();
	for (int i = 0; i < rectangleLength; i++)
	{
		for (int j = 0; j < rectangleWidth; j++)
		{				
			if ( i == 0  || i == rectangleLength - 1)
			{
				cout << border;
			}else if ( j == 0  || j == rectangleWidth - 1)
			{
				cout << border;
			}
			else 
			{
				cout << fill;
			}
		}
		cout << "\n";
	}
		
}

void doEverything()	
{
	setRectangleLength();
	setRectangleWidth();
	calculatePerimeter();
	calculateArea();
	draw();
}

void lengthc()// function increments the number of the rectangle when asking for length
{
	static int l = 0;
	l++;
	cout << l;
}

void widthc()// function increments the number of the rectangle when asking for width
{
	static int w = 0;
	w++;
	cout << w;
}
	

private: // length and width as private data members
	int rectangleLength;
	int rectangleWidth;
	int rPerimeter;
	int rArea;
	char border;
	char fill;
	char rArray[5];
};

int main()
{
	Rectangle rA[5];
	rA[0].doEverything();
	rA[1].doEverything();
	rA[2].doEverything();
	rA[3].doEverything();
	rA[4].doEverything();


	

	return 0;
}

Recommended Answers

All 3 Replies

lengthc and widthc both return void.

If you want to use a function as part of an output stream it has to return something. Neither lengthc() nor widthc() return anything.

[edit]
Ack!!!.. Ninja Narue!!...run!!

lengthc and widthc both return void.

lol me and my stupid mistakes....thx for yout help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.