1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#ifndef rectangleType_h
#define rectangleType_h
#include <iostream>
using namespace std;
class rectangleType
{
friend ostream& operator<<(ostream&, const rectangleType&);//overloads stream insertion operator
friend istream& operator>>(istream&, rectangleType&);//overloads extraction operators
friend rectangleType operator++(rectangleType&);//pre-increment
friend rectangleType operator--(rectangleType&);//pre-decrement
friend rectangleType operator++(rectangleType&, int);//post - increment
friend rectangleType operator--(rectangleType&, int);//post-decrement
friend rectangleType operator+(const rectangleType&, const rectangleType&);//overload + operator
friend rectangleType operator-(const rectangleType&, const rectangleType&);//overload - operator
friend rectangleType operator*(const rectangleType&, const rectangleType&);//overload * operator
friend bool operator==(const rectangleType&, const rectangleType&);//overload == operator, relational
friend bool operator!=(const rectangleType&, const rectangleType&);//overload != operator
friend bool operator<=(const rectangleType&, const rectangleType&);//overload <= operator
friend bool operator<(const rectangleType&, const rectangleType&);//overload < operator
friend bool operator>=(const rectangleType&, const rectangleType&);//overload >= operator
friend bool operator>(const rectangleType&, const rectangleType&);//overload>+ operator
public:
void setDimension(double l, double w);
double getLength() const;
double getWidth() const;
double area() const;
double perimeter() const;
rectangleType();//class constructor
rectangleType(double l, double w);//class constructor with parameters
protected:
double length;
double width;
};
#endif
|