can someone help me with this, or just help get me started.

write the definitions of the functions to overload the increment, decrement, arithmetic, and relational operators as a member of the class rectangeType.

write a test program that tests various operations on the class rectangleType

This might give you a start for how to define them:

#include <iostream>
#include <utility>

class Integer {
  int _val;
public:
  Integer(): _val(0) {}
  Integer(int val): _val(val) {}
  int get() const { return _val; }

  Integer operator+=(const Integer& rhs) { return _val += rhs._val; }
  Integer operator-=(const Integer& rhs) { return _val -= rhs._val; }
  Integer operator*=(const Integer& rhs) { return _val *= rhs._val; }
  Integer operator/=(const Integer& rhs) { return _val /= rhs._val; }
  Integer operator%=(const Integer& rhs) { return _val %= rhs._val; }

  Integer operator+(const Integer& rhs) { return _val + rhs._val; }
  Integer operator-(const Integer& rhs) { return _val - rhs._val; }
  Integer operator*(const Integer& rhs) { return _val * rhs._val; }
  Integer operator/(const Integer& rhs) { return _val / rhs._val; }
  Integer operator%(const Integer& rhs) { return _val % rhs._val; }

  Integer operator++() { return *this += 1; }
  Integer operator++(int) { Integer temp(*this); ++*this; return temp; }
  Integer operator--() { return *this -= 1; }
  Integer operator--(int) { Integer temp(*this); --*this; return temp; }

  friend bool operator==(const Integer& lhs, const Integer& rhs)
  { return lhs._val == rhs._val; }
  friend bool operator<(const Integer& lhs, const Integer& rhs)
  { return lhs._val < rhs._val; }
};

int main()
{
  using namespace std::rel_ops; // Sneaky sneaky ;-)

  Integer a(20);

  // Op-assign operators
  std::cout << a.get() <<'\n';
  a += 2;
  std::cout << a.get() <<'\n';
  a -= 2;
  std::cout << a.get() <<'\n';
  a *= 2;
  std::cout << a.get() <<'\n';
  a /= 2;
  std::cout << a.get() <<'\n';
  a %= 2;
  std::cout << a.get() <<'\n';

  a = 20;
  Integer c;

  // Arithmetic operators
  std::cout << c.get() <<'\n';
  c = a + 2;
  std::cout << c.get() <<'\n';
  c = a - 2;
  std::cout << c.get() <<'\n';
  c = a * 2;
  std::cout << c.get() <<'\n';
  c = a / 2;
  std::cout << c.get() <<'\n';
  c = a % 2;
  std::cout << c.get() <<'\n';

  a = 20;

  // Increment/decrement
  std::cout << (++a).get() <<'\n';
  std::cout << (a++).get() <<'\n';
  std::cout << (--a).get() <<'\n';
  std::cout << (a--).get() <<'\n';

  a = 20;
  c = 20;

  // Relational operators
  std::cout << (a == c) << '\n';
  std::cout << (a != c) << '\n';
  std::cout << (a < c) << '\n';
  std::cout << (a <= c) << '\n';
  std::cout << (a > c) << '\n';
  std::cout << (a >= c) << '\n';
}
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.