EX7_01.cpp

  1. Based on Ex7_01.cpp, write a function bool equalAreaRect(const Rectangle& a, const Rectangle& b) which compares the area of two rectangles.
  2. You may test your function with the following main() function:
    
    int main(void)
    {
      Rectangle Pool = { 30, 40, 70, 80 };
      Rectangle Hut1, Hut2;
    
      Hut1.left = 70;
      Hut1.top = 10;
      Hut1.right = Hut1.left + 25;
      Hut1.bottom = 30;
    
      Hut2 = Hut1;                         // Define Hut2 the same as Hut1
      moveRect(Hut2, 10, 90);              // Now move it to the right position
    
      if ( equalAreaRect(Hut1, Hut2) )
          cout << "The areas of Hut1 and Hut2 are "
               << "the same.\n";
      else
          cout << "The areas of Hut1 and Hut2 are "
               << "different.\n";
    
      cout << "The areas of Pool and Hut1 are "
           << (equalAreaRect(Pool, Hut1)?"the same":"different")
           << ".\n";
    
      return 0;
    }