Question: main.cpp #include using namespace std; int main() { // Write your main here return 0; } rectangleType.cpp #include #include #include rectangleType.h using namespace std; void

 main.cpp #include using namespace std; int main() { // Write your

main.cpp

#include

using namespace std;

int main() {

// Write your main here

return 0;

}

rectangleType.cpp

#include

#include

#include "rectangleType.h"

using namespace std;

void rectangleType::setDimension(double l, double w)

{

if (l >= 0)

length = l;

else

length = 0;

if (w >= 0)

width = w;

else

width = 0;

}

double rectangleType::getLength() const

{

return length;

}

double rectangleType::getWidth()const

{

return width;

}

double rectangleType::area() const

{

return length * width;

}

double rectangleType::perimeter() const

{

return 2 * (length + width);

}

rectangleType::rectangleType(double l, double w)

{

setDimension(l, w);

}

rectangleType::rectangleType()

{

length = 0;

width = 0;

}

rectangleType rectangleType::operator++()

{

//increment the length and width

++length;

++width;

return *this; //return the incremented value of the object

}

rectangleType rectangleType::operator++(int u)

{

rectangleType temp = *this; //use this pointer to copy

//the value of the object

//increment the length and width

length++;

width++;

return temp; //return the old value of the object

}

rectangleType rectangleType::operator--()

{

//Decrement the length and width

assert(length != 0 && width != 0);

--length;

--width;

return *this; //return the incremented value of the object

}

rectangleType rectangleType::operator--(int u)

{

rectangleType temp = *this; //use this pointer to copy

//the value of the object

//Decrement the length and width

assert(length != 0 && width != 0);

length--;

width--;

return temp; //return the old value of the object

}

rectangleType rectangleType::operator+

(const rectangleType& rectangle) const

{

rectangleType tempRect;

tempRect.length = length + rectangle.length;

tempRect.width = width + rectangle.width;

return tempRect;

}

rectangleType rectangleType::operator-

(const rectangleType& rectangle) const

{

rectangleType tempRect;

assert(length >= rectangle.length &&

width >= rectangle.width);

tempRect.length = length - rectangle.length;

tempRect.width = width - rectangle.width;

return tempRect;

}

rectangleType rectangleType::operator*(const rectangleType& rectangle) const

{

rectangleType tempRect;

tempRect.length = length * rectangle.length;

tempRect.width = width * rectangle.width;

return tempRect;

}

bool rectangleType::operator==

(const rectangleType& rectangle) const

{

return (area() == rectangle.area());

}

bool rectangleType::operator!=

(const rectangleType& rectangle) const

{

return (area() != rectangle.area());

}

bool rectangleType::operator

(const rectangleType& rectangle) const

{

return (area()

}

bool rectangleType::operator

(const rectangleType& rectangle) const

{

return (area()

}

bool rectangleType::operator>=

(const rectangleType& rectangle) const

{

return (area() >= rectangle.area());

}

bool rectangleType::operator>

(const rectangleType& rectangle) const

{

return (area() > rectangle.area());

}

ostream& operator

const rectangleType& rectangle)

{

osObject

return osObject;

}

istream& operator>>(istream& isObject, rectangleType& rectangle)

{

isObject >> rectangle.length >> rectangle.width;

return isObject;

}

rectangleType.h

#ifndef H_rectangleType

#define H_rectangleType

#include

using namespace std;

class rectangleType

{

//Overload the stream insertion and extraction operators

friend ostream& operator

friend istream& operator>>(istream&, rectangleType &);

public:

void setDimension(double l, double w);

double getLength() const;

double getWidth() const;

double area() const;

double perimeter() const;

//Overload the arithmetic operators

rectangleType operator + (const rectangleType &) const;

rectangleType operator - (const rectangleType &) const;

rectangleType operator * (const rectangleType&) const;

//Overload the increment and decrement operators

rectangleType operator ++ (); //pre-increment

rectangleType operator ++ (int); //post-increment

rectangleType operator -- (); //pre-decrement

rectangleType operator -- (int); //post-decrement

//Overload the relational operators

bool operator == (const rectangleType&) const;

bool operator != (const rectangleType&) const;

bool operator

bool operator

bool operator >= (const rectangleType&) const;

bool operator > (const rectangleType&) const;

//constructors

rectangleType();

rectangleType(double l, double w);

protected:

double length;

double width;

};

#endif

Contact GitHub API Training Shop Blog About

2017 GitHub, Inc. Terms Privacy Security Status Help

Overloading Operators as Non-members Instructions Grading When you have completed your program, click the Submit button to record your score

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!