0

I want to create a typedef that holds cartesian coordinates of a 3D point, and gives two different ways to access these coordinates.
Ideally, if my variable is point3D, I would like to be able to write both of these :

point3D->x = 0.0;
point3D->y = 0.0;
point3D->z = 0.0;

AND

point3D[x] = 0.0;
point3D[y] = 0.0;
point3D[z] = 0.0;

I know that unions could do the trick. But, I do not know how to use it without creating intermediate structure/array names inside of it.

Is there a proper way to do it as shown above ?

MMasmoudi
  • 508
  • 1
  • 5
  • 19

0 Answers0