See user-defined conversion function
]. That's a great site, by the way. My go-to for obscure C++ information.
So if you're trying to convert between
, it would be something like this:
operator Vec3(const Vector3& v); operator Vector3(); };
operator Vector3(const Vec3& v); operator Vec3(); };
And now each vector has both versions.
: Those were converting constructors. If you want a conversion operator
, it has to go in the class being converted. I've edited the above to show them. You can make any of the converters
if you have problems with unintended conversions, but I don't think that will happen here. It's more likely when providing conversion to basic types, like
From the above,
v1a = v2a;
should invoke the conversion operator