title: Finding 4th vertex of a rectangle
body: <p>I need my code to find the 4th vertex of a rectangle. Tried to make something but as always failed. It works in some cases, bot not everytime. Could someone help me with it? 
  Also, it has to be done with 2 classes, one for vertices and other one for a whole rectangle.
  Problem is that my code works for a certain vertex setting. I was trying many things but still fail. </p>
  
  <p>Here's the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cmath&gt;
  using namespace std;
  
  class vertex{
      public: 
          double x;
          double y;
          void insert(){
              cin&gt;&gt;x;
              cin&gt;&gt;y;
          }
  };
  
  class rect{
      private:
          double ax, ay, bx, by, cx, cy, dx, dy;
      public:
          void insert_data(vertex A, vertex B, vertex C){         //inserting rectangle data
              ax=A.x;
              ay=A.y;
              bx=B.x;
              by=B.y;
              cx=C.x;
              cy=C.y;
          }
          void calculate(){           //finding 4h vertex coordinates
          dx=cx+(abs(ax-bx));
          dy=cy+(abs(ay+by));
          }       
          void out(){                 //output
              cout&lt;&lt;dx&lt;&lt;" "&lt;&lt;dy;
          }
  
  };
  
  
  
  
  
  using namespace std;
  
  int main() {
      vertex A, B, C;
      A.insert();
      B.insert();
      C.insert();
      rect X;
      X.insert_data(A, B, C);
      X.calculate();
      X.out();
  
  
      return 0;
  }
  </code></pre>
  
  <p>As I think about it now it may have something to do with inserting the coordinates to the right variables, but can't think of a solution to fix this.</p>
  
  <p>For example:<br>
  Input: <br>
  1 1 <br>
  0 3 <br>
  3 2 <br>
  Output:<br>
  2 4</p>
  
  <p>Order of inputing each vertex is not specified.</p>