title: Inheritance of operator overloads
body: <p>I'm having an issue with the inheritance of my operator overloading functions in my derived class. </p>
  
  <pre><code>#pragma once
  
  #include "Math.hpp"
  
  using namespace Math;
  
  class Euler
  {
  public:
      float   x, y, z;
  
      Euler();
      Euler(const float &amp;, const float &amp;, const float &amp;);
  
      float   &amp;operator[](const char &amp;) const;
      Euler   &amp;operator=(const Euler &amp;);
  
      Euler   &amp;operator+=(const Euler &amp;);
      Euler   &amp;operator-=(const Euler &amp;);
      Euler   &amp;operator*=(const float &amp;);
      Euler   &amp;operator/=(const float &amp;);
  
      Euler   operator+(const Euler &amp;) const;
      Euler   operator-(const Euler &amp;) const;
      Euler   operator*(const float &amp;) const;
      Euler   operator/(const float &amp;) const;
  
      bool    operator==(const Euler &amp;) const;
      bool    operator!=(const Euler &amp;) const;
  
      bool    IsValid() const;
      void    Clear();
  };
  
  
  inline Euler::Euler()
  {
      x = y = z = 0.f;
  }
  
  inline Euler::Euler(const float &amp;_x, const float &amp;_y, const float &amp;_z)
  {
      x = _x;
      y = _y;
      z = _z;
  }
  
  inline float &amp;Euler::operator[](const char &amp;c) const
  {
      return ((float *)this)[c];
  }
  
  inline Euler &amp;Euler::operator=(const Euler &amp;e)
  {
      x = e.x;
      y = e.y;
      z = e.z;
  
      return *this;
  }
  
  inline Euler &amp;Euler::operator+=(const Euler &amp;e)
  {
      x += e.x;
      y += e.y;
      z += e.z;
  
      return *this;
  }
  
  inline Euler &amp;Euler::operator-=(const Euler &amp;e)
  {
      x -= e.x;
      y -= e.y;
      z -= e.z;
  
      return *this;
  }
  
  
  inline Euler &amp;Euler::operator*=(const float &amp;e)
  {
      x *= e;
      y *= e;
      z *= e;
  
      return *this;
  }
  
  inline Euler &amp;Euler::operator/=(const float &amp;e)
  {
      x /= e + M_FLT_EPSILON;
      y /= e + M_FLT_EPSILON;
      z /= e + M_FLT_EPSILON;
  
      return *this;
  }
  
  inline Euler Euler::operator+(const Euler &amp;e) const
  {
      return Euler(x + e.x, y + e.y, z + e.z);
  }
  
  inline Euler Euler::operator-(const Euler &amp;e) const
  {
      return Euler(x - e.x, y - e.y, z - e.z);
  }
  
  inline Euler Euler::operator*(const float &amp;f) const
  {
      return Euler(x * f, y * f, z * f);
  }
  
  inline Euler Euler::operator/(const float &amp;f) const
  {
      return Euler(x / (f + M_FLT_EPSILON), y / (f + M_FLT_EPSILON), z / (f + M_FLT_EPSILON));
  }
  
  inline bool Euler::operator==(const Euler &amp;e) const
  {
      return e.x == x &amp;&amp; e.y == y &amp;&amp; e.z == z;
  }
  
  inline bool Euler::operator!=(const Euler &amp;e) const
  {
      return e.x != x || e.y != y || e.z != z;
  }
  
  inline bool Euler::IsValid() const
  {
      using namespace std;
  
      return isfinite(x) &amp;&amp; isfinite(y) &amp;&amp; isfinite(z);
  }
  
  inline void Euler::Clear()
  {
      x = y = z = 0.f;
  }
  
  class Vector : public Euler
  {
  public:
      using Euler::Euler;
  
      void    Rotate(const Angle &amp;);
      void    Rotate2D(const float &amp;);
  
      float   Length() const;
      float   LengthSqr() const;
      float   Length2D() const;
      float   Length2DSqr() const;
  
      float   DistTo(const Vector &amp;) const;
      float   DistToSqr(const Vector &amp;) const;
  };
  
  inline float Vector::Length() const
  {
      return Sqrt((x * x) + (y * y) + (z * z));
  }
  
  inline float Vector::LengthSqr() const
  {
      return (x * x) + (y * y) + (z * z);
  }
  
  inline float Vector::Length2D() const
  {
      return Sqrt((x * x) + (y * y));
  }
  
  inline float Vector::Length2DSqr() const
  {
      return (x * x) + (y * y);
  }
  
  inline float Vector::DistTo(const Vector &amp;v) const
  {
      return (*this - v).Length();
  }
  
  inline float Vector::DistToSqr(const Vector &amp;v) const
  {
      return (*this - v).LengthSqr();
  }
  </code></pre>
  
  <p>The code shown below contains an error in the distto and DistToSqr function wherein it calculates (*this - v) as the superclass Euler and therefore cannot find the length function.</p>
  
  <p>I was wondering why this would be as this code compiles on my laptop and not my desktop.</p>
  
  <p><img src="https://i.imgur.com/qerfsnW.png" alt=""></p>
  
  <p>I'd be grateful if anyone could show me why this code doesn't work and what is the best course in fixing it.</p>
  
  <hr>
  
  <p>It seems like doing this is a plausible way to fix it.</p>
  
  <pre><code>inline float Vector::DistTo(const Vector &amp;v) const
  {
      Vector tmp = (*this - v);
      return tmp.Length();
  }
  </code></pre>
  
  <p>Still wondering if this is the best option to fix it though.</p>