title: Having trouble with a C++ Square Class. Member function implementation and declaration
body: <p>My last question was closed after 2 minutes. I am simply asking for help with the member functions. I should have member functions checking the following:</p>
  
  <ol>
  <li>whether the square is external to another;</li>
  <li>whether the square contains another square;</li>
  <li>whether the square is contained into another square;</li>
  <li>whether the square is tangent externally to another square (that is,
  whether their borders are in contact but, except those border
  points, they are external to each other);</li>
  <li>whether the square is tangent internally to another square (that is,
  they have points on the borders in common but, except those border
  points, one square is contained into the other one);</li>
  <li>whether the border of the square intersects the border of another
  square.</li>
  </ol>
  
  <p>my private members are: double x,y;</p>
  
  <p>Should i have the public member functions then, using both x and y to compute the perimeter and area?</p>
  
  <p>This is what i have so far:
  the header file</p>
  
  <pre><code>#include  &lt;iostream&gt;
  #include  &lt;cmath&gt;
  class Square
  {
  int x, y;
  int  size;
  
  public:
  Square(int x, int y, int size) : x(x), y(y), size(size) { }
  ~Square() {};
  bool isExternal(const Square&amp; rhs);
  bool contains(const Square&amp; otherSquare);
  bool iscontained(const Square&amp; otherSquare);
  
  bool borderintersect (const Square&amp; otherSquare);
  bool bordertangent (const Square&amp; otherSquare);
  }
  </code></pre>
  
  <p>The implementation</p>
  
  <pre><code>#include "Square.h"
  
  
  bool Square::isExternal(const Square&amp; rhs) const {
      return (((x &lt; rhs.x) || ((x + size) &gt; (rhs.x + rhs.size)) &amp;&amp;  ((y &lt; rhs.y) || ((y + size) &gt; (rhs.y + rhs.size)) 
  };
  bool Square::contains(const Square&amp; otherSquare)const {
  };
  bool Square::iscontained(const Square&amp; otherSquare)const {
  };
  
  bool borderintersect(const Square&amp; othersquare)
  {
  // If this square's bottom is greater than the other square's top
  if ((this-&gt;y - (this-&gt;size / 2)) &gt; (othersquare-&gt;y + (othersquare-&gt;size / 2)))
  {
      return (false);
  }
  // the reverse
  if ((this-&gt;y + (this-&gt;size / 2)) &lt; (othersquare-&gt;y - (othersquare-&gt;size / 2)))
  {
      return (false);
  }
  // If this square's left is greater than the other square's right
  if ((this-&gt;x - (this-&gt;size / 2)) &gt; (othersquare-&gt;x + (othersquare-&gt;size / 2)))
  {
      return (false);
  }
  
  if ((this-&gt;x + (this-&gt;size / 2)) &lt; (othersquare-&gt;x - (othersquare-&gt;size / 2)))
  {
      return (false);
  }
  return (true);
  
  bool Square::bordertangent (const Square&amp; otherSquare)const {
  };
  </code></pre>
  
  <p>The test program</p>
  
  <pre><code>#include "Square.h"
  #include &lt;iostream&gt;
  using namespace std;
  </code></pre>
  
  <p> 
      int main() {</p>
  
  <pre><code>Square sq1(0, 0, 10);
  Square sq2(1, 1, 10);
  
      if(sq1.isExternal(sq2)) {
      cout&lt;&lt;"Square 1 is external to square 2"&lt;&lt;endl;
  }
  
  if(sq1.contains(sq2){
      cout&lt;&lt;"Square 1 contains square 2"&lt;&lt;endl;
  
  return 0;
  }
  </code></pre>
  
  <p>Should i include this in the header file in order to get both the x and y of the coordinate and the size?</p>
  
  <pre><code>double  getX( )  const {  return x;  }
  double  getY( )  const {  return y;  }
  double  getSize( )  const {  return size;  }               
  </code></pre>