Physics vector constructor, magnitude and unit vector functions not working c++ : <p>I am writing a class called Vector which represents a 3-dimensional vector. I need a constructor which can take a pre-existing Vector object and create a new one from it. This is the constructor:</p>

<pre><code>Vector::Vector(const Vector &amp;v1){
    for(int i = 0; i &lt; d; i++)
        components[i] = v1.components[i];
}
</code></pre>

<p>This is the note the compiler gives me:</p>

<pre><code>candidate constructor not viable: no known conversion from 'Vector *' 
to 'const Vector &amp;' for 1st argument; dereference the argument with *
Vector::Vector(const Vector &amp;v1){
</code></pre>

<p>I also have a magnitude function:</p>

<pre><code>double Vector::magnitude(){
    return std::pow(dot(this, this), 0.5);
}
</code></pre>

<p>I come from java so by the use of this I mean to say use this instance of the class and pass it in as a Vector to the dot function. I get the following error:</p>

<pre><code>error: no viable conversion from 'Vector *' to 'Vector'
return std::pow(dot(this, this), 0.5);
</code></pre>

<p>I also have a unit vector function where I try to use my constructor above to create a copy of the Vector object using <code>this</code>.</p>

<pre><code>Vector Vector::getUnitVector(){
    Vector unit(this);
    unit.scale(1/unit.magnitude());
    return unit;
}
</code></pre>

<p>I get the following error:</p>

<pre><code>error: no matching constructor for initialization of 'Vector'
Vector unit(this);
</code></pre>

<p>How can I fix these errors? Thank you.</p>
