c++ error:no suitable conversion function from "math::Vec3<float>" to "float" exists
<ul>
<li>I get error C2440: '=' : cannot convert from 'math::Vec3' to 'float' but i don't understand why. I think <strong>buffer is Vec3 type</strong> and <strong>v object is type Vec3</strong> also.</li>
<li>The <strong>Vec3 class</strong> is used as a generic three-dimensional vector and thus it defines several numerical operators that can be used on Vec3 and S data.</li>
</ul>

<p><strong>Image.h</strong></p>

<pre><code>#ifndef _IMAGE
#define _IMAGE

#include "Array.h"
#include "Serializable.h"
#include "Vec3.h"

using namespace math;

 class Image : public Array&lt;Vec3&lt;float&gt;&gt;, public Serializable

 {
 public:
    enum channel_t { RED = 0, GREEN, BLUE };          
 protected:
     Vec3&lt;float&gt; *buffer;    
 public:
     Vec3&lt;float&gt; getPixel(unsigned int x, unsigned int y) const;
  /*code*/
};

#endif
</code></pre>

<p><strong>Image.cpp</strong></p>

<pre><code>#include "Image.h"
using namespace math;

 Vec3&lt;float&gt; Image::getPixel(unsigned int x, unsigned int y) const  {
 math::Vec3&lt;float&gt; v;
 int s = 0;

 if ((x &lt;= Image::getWidth()) &amp;&amp; (y &lt;= Image::getHeight()) &amp;&amp; (x &gt;= 0) &amp;&amp; (y &gt;= 0))
 {

    for (unsigned int i = 1; i == getWidth(); i++)
    {
        for (unsigned int j = 1; i == getHeight(); j++)
        {
            if (i == x - 1 &amp;&amp; j == y - 1)
                goto label;
            else
                s = s + 3;
        }
    }
 label:
    v[Image::RED] = buffer[s + RED];       &lt;-------------------HERE 
    v[Image::GREEN] = buffer[s + GREEN];   &lt;-------------------I GET AN
    v[Image::BLUE] = buffer[s + BLUE];     &lt;-------------------ERROR
 }
 return v;
 }//end of getPixel
</code></pre>

<p><strong>Vec3.h</strong></p>

<pre><code>#ifndef _Vec3_ 
#define _Vec3_

namespace math

{

template &lt;typename S&gt;
 class Vec3
 {
 public:
    // data members

    //! The first coordinate of the vector
    union { S x, r; }; 

    //! The second coordinate of the vector
    union { S y, g; }; 

    //! The third coordinate of the vector
    union { S z, b; }; 

    S &amp; operator [] (size_t index)
    {
        return *((S*)this + index);
    }

    Vec3&lt;S&gt; operator + (const Vec3&lt;S&gt; &amp; right)
    {
        Vec3&lt;S&gt; left;
        left.x = x + right.x;
        left.y = y + right.y;
        left.z = z + right.z;
        return left;
    }

    Vec3&lt;S&gt; operator - (const Vec3&lt;S&gt; &amp; right)
    {
        Vec3&lt;S&gt; left;
        left.x = x - right.x;
        left.y = y - right.y;
        left.z = z - right.z;
        return left;
    }

    Vec3&lt;S&gt; operator * (const Vec3&lt;S&gt; &amp; right)
    {
        Vec3&lt;S&gt; left;
        left.x = x * right.x;
        left.y = y * right.y;
        left.z = z * right.z;
        return left;
    }

    Vec3&lt;S&gt; operator * (S right)
    {
        Vec3&lt;S&gt; left;
        left.x = x * right;
        left.y = y * right;
        left.z = z * right;
        return left;
    }

    Vec3&lt;S&gt; operator / (S right)
    {
        Vec3&lt;S&gt; left;
        left.x = x / right;
        left.y = y / right;
        left.z = z / right;
        return left;
    }

    Vec3&lt;S&gt; operator / (const Vec3&lt;S&gt; &amp; right)
    {
        Vec3&lt;S&gt; left;
        left.x = x / right.x;
        left.y = y / right.y;
        left.z = z / right.z;
        return left;
    }

    Vec3&lt;S&gt; &amp; operator += (const Vec3&lt;S&gt; &amp; right)
    {
        x += right.x;
        y += right.y;
        z += right.z;
        return *this;
    }

    Vec3&lt;S&gt; &amp; operator -= (const Vec3&lt;S&gt; &amp; right)
    {
        x -= right.x;
        y -= right.y;
        z -= right.z;
        return *this;
    }

    Vec3&lt;S&gt; &amp; operator /= (const Vec3&lt;S&gt; &amp; right)
    {
        x /= right.x;
        y /= right.y;
        z /= right.z;
        return *this;
    }

    Vec3&lt;S&gt; &amp; operator *= (const Vec3&lt;S&gt; &amp; right)
    {
        x *= right.x;
        y *= right.y;
        z *= right.z;
        return *this;
    }

    Vec3&lt;S&gt; &amp; operator *= (S right)
    {
        x *= right;
        y *= right;
        z *= right;
        return *this;
    }

    Vec3&lt;S&gt; &amp; operator /= (S right)
    {
        x /= right;
        y /= right;
        z /= right;
        return *this;
    }

    Vec3&lt;S&gt;(S x, S y, S z) : x(x), y(y), z(z) {}

    Vec3&lt;S&gt;(S val) : x(val), y(val), z(val) {}

    Vec3&lt;S&gt;() : x(), y(), z() {}

    Vec3&lt;S&gt;(const Vec3&lt;S&gt; &amp; right) : x(right.x), y(right.y), z(right.z) {}

    Vec3&lt;S&gt; &amp; operator = (const Vec3&lt;S&gt; &amp; right)
    {
        x = right.x;
        y = right.y;
        z = right.z;
        return *this;
    }

    bool operator == (const Vec3&lt;S&gt; &amp; right) const
    {
        return x == right.x &amp;&amp; y == right.y &amp;&amp; z == right.z;
    }

    bool operator != (const Vec3&lt;S&gt; &amp; right) const
    {
        return x != right.x || y != right.y || z != right.z;
    }
  };

  template&lt;typename S&gt;
  Vec3&lt;S&gt; operator * (S a, Vec3&lt;S&gt; v)
  {
    return v*a;
  }


  template&lt;typename S&gt;
  Vec3&lt;S&gt; operator * (int a, Vec3&lt;S&gt; v)
  {
    return v*S(a);
  }

  template&lt;typename S&gt;
  Vec3&lt;S&gt; operator * (Vec3&lt;S&gt; v, int a)
  {
    return v*S(a);
  }

  template&lt;typename S&gt;
  Vec3&lt;S&gt; operator / (Vec3&lt;S&gt; v, int a)
  {
    return v/S(a);
  }
} // namespace math

#endif
</code></pre>