Why not just do this:
void Vec3::SetCoord(const Point& pnt)
{
x = pnt.x;
y = pnt.y;
z = pnt.z;
}
OR...
Make a new overloaded constructor:
Vec3::Vec3(const Point& pnt)
{
x = pnt.x;
y = pnt.y;
z = pnt.z;
}
No crazy casting or equals operator involved. I'd recommend doing one of these ways, its probably the easiest to maintain.
To get the equals-syntax above should really add a type conversion operator, but to Point:
class Point
{
// ....
operator Vec3()
{
return Vec3(this->x,this->y,this->z);
}
};
Doing an assignment between the two objects like that is kinda funny without assuming a type-conversion. Most classes don't behave that way syntactically.
Note, though, that this can cause some ambiguity, and a number of well-respected folks on this site who answer questions on C++ would say the type-conversion answer can cause all sorts of nasty issues. So I'd avoid it.