title: coding base on UML diagram c++
body: <p>I have a Line class UML diagram which shows the following details</p>
  
  <pre><code> - pOne: Point
   - pTwo: Point
   + Line (ptOne: Point, ptTwo: Point)
   + getPOne () : Point
   + getPTwo () : Point
   + setPOne (pOne: Point) 
   + setPTwo (pTwo: Point)
  </code></pre>
  
  <p>)</p>
  
  <p>this is what I have done according to my interpretation of the UML diagram</p>
  
  <p>Line.h</p>
  
  <pre><code>#ifndef __testing__Line__
  #define __testing__Line__
  #include &lt;iostream&gt;
  #include "Point"
  
  class Line  {
  
  private:
     //pOne and pTwo are objects of Point 
     Point pOne;
     Point pTwo;
  
  public:
  
      Line() {
  
      };//default Constructor
  
      // constructor of class Line to store objects of Point(pOne,pTwo)
      Line (Point pOne,Point pTwo);
  
      // get method for objects of Point(pOne,pTwo)
      Point getPOne();
      Point getPTwo();
  
      // set method for objects of a(one,two)
      void setPOne (Point pOne);
      void setPTwo (Point pTwo);
  
  };
  #endif /* defined(__testing__Line__) */
  </code></pre>
  
  <p>Line.cpp</p>
  
  <pre><code>#include "Line.h"
  
  Line::Line (Point pOne, Point pTwo)  {
      setPOne(pOne);
      setPTwo(pTwo);
  }
  
  Point Line::getPOne()    {
      return pOne;
  }
  
  Point Line::getPTwo()    {
      return pTwo;
  }
  
  Line::setPOne (Point pOne)   {
       this-&gt; pOne = pOne;
  }
  
  Line::setATwo (Point pTwo)   {
       this-&gt;pTwo = pTwo;
  }
  </code></pre>
  
  <p>and in main cpp I tried to call the function getPOne()</p>
  
  <p>main.cpp</p>
  
  <pre><code>#include "Point"
  #include "Line"
  
  int main() {
      Line outputMethod;
      //Invalid operands to binary expression
      std::cout &lt;&lt; outputMethod.getPOne() &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>How should I call getPOne() from Line class given in the above situation?</p>
  
  <hr>
  
  <p>operator overloading</p>
  
  <pre><code>//overload &lt;&lt; operator
  friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, Point&amp;)
  {
    return os;
  }
  </code></pre>