dimension and x,y,z components时间:2021-12-26 19:16:49class Point3 { public: union { struct { int x, y, z; }; int val[3]; }; 引用的时候可以写成: Point3 p; int dimension = 1; p.val[dimension]