I have a structure representing the top. It has fields x, y and z, as well as several others. Recently, I came to the conclusion that for certain functionality I will need to access the coordinates of the vertices in the form of an array. I did not want to "pollute" the code with temporary variables or change all places that look like vy to this v.coord[1] , which is neither cute nor elegant. So I thought about using union. Something like this should work:
struct { float x,y,z; } Point; struct { union { float coord[3]; Point p; }; } Vertex;
This is good, but not perfect. A point class does not make sense. I want to have access to the y coordinate just by typing vy (not vpy ).
Can you suggest hacking this solution (or say that this is impossible)?
c ++ c
Artium
source share