I am trying to override the = operator so that I can change my Point class into a Vector3 class.
Point tp = p2 - p1;
Vec3 v;
v = tp;
The problem I am facing is that, “v” will have its x,y,z members equal to zero all the time.
Vec3.h:
Vec3 operator =(Point a) const;
Vec3.cpp:
Vec3 Vec3::operator =(Point a) const
{
return Vec3(a.x,a.y,a.z);
}
Thanks for all the help once again 🙂
It’s been a while, but I think you want
Assignment modifies ‘this’, so it can’t be const. It doesn’t return a new Vec3, it modifies an existing one. You will also probably want a copy constructor from Point, that does the same.