I want to be able to use math functions on my “vector3D”s like so
vector3D a = v3d(1.0,1.0,1.0);
vector3D b = v3d(2.0,0.0,5.0);
a+=b;
vector3D c = a*b;
The code for my typedef struct:
typedef struct _vector3D{
float x;
float y;
float z;
}vector3D;
static inline vector3D
v3d(const float x, const float y, const float z)
{
vector3D v = {x,y,z};
return v;
}
How do I allow my typedef struct vector3D to handle this operators?
C, and therefore Objective-C, does not support method overloading.
You’ll have to write your own
addandmultiplyfunctions instead.