title: Polymorphism vs Inheritance. Diffrence?
body: <p>I dont understand the diffrence between Polymorphism and Inheritance... They Litterarly do the same thing...</p>
  
  <p>Simple Example Of Polymorphism:</p>
  
  <pre><code>    class shape {
      public:
          void setValues(int height_, int width_) {
              height = height_, width = width_;
          }
      protected:
          int height, width;
  
      private:
  
      };
  
      class rectangle :public shape, public ThreeDView{
      public:
          int area() {
              return(shape::height*shape::width);
          }
          float threeDArea() {
              return(((shape::height*shape::width)/2)*(std::cos(Z_LENGTH)));
          }
      };
  
  class ThreeDView{
  public:
      void setZLength(int value) {
          Z_LENGTH = value;
      }
  
      int setCompact(bool ans) {
          compact = ans;
      }
  
      float getZLength() {
          return Z_LENGTH;
      }
  
      bool getCOMPACT() {
          return compact;
      }
  protected:
      float Z_LENGTH;
      bool compact;
  
  private:
      unsigned char ZCHAR = 'Z';
  };
  
  
      class triangle :public shape {
      public:
          int area() {
              return((shape::height * shape::width) / 2);
          }
      };
  
      int main(){
      rectangle rect2;
          triangle trng2;
          shape *poly = &amp;rect2;
          shape *poly2 = &amp;trng2;
  
          poly-&gt;setValues(2,3);
          poly2-&gt;setValues(5,4);
          std::cout &lt;&lt; "AREA : " &lt;&lt; trng1.area() &lt;&lt; "AREA RECT : \n" &lt;&lt;rect1.area() &lt;&lt; std::endl;
      }
  </code></pre>
  
  <p>Above example translated to Inheritance:</p>
  
  <pre><code>class shape {
  public:
      void setValues(int height_, int width_) {
          height = height_, width = width_;
      }
  protected:
      int height, width;
  
  private:
  
  };
  
  class rectangle :public shape, public ThreeDView{
  public:
      int area() {
          return(shape::height*shape::width);
      }
      float threeDArea() {
          return(((shape::height*shape::width)/2)*(std::cos(Z_LENGTH)));
      }
  };
  
  class triangle :public shape {
  public:
      int area() {
          return((shape::height * shape::width) / 2);
      }
  };
  
  int main(){
  rectangle rect2;
   triangle trng2;
  
      rect2.setValues(2,3);
      trng2.setValues(5,4);
      std::cout &lt;&lt; "AREA : " &lt;&lt; trng1.area() &lt;&lt; "AREA RECT : \n" &lt;&lt;rect1.area() &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>Please tell me diffrence. Honestly i dont even see the use of Polymorphism! Thanks for helping!</p>