我想定义这样一个类型:
typedef union {
struct { float x,y,z,w;};
float v[4];
} vec4f;
这样就可以:
vec4f v4f;
v4f.x = ...;
v4f.v[1] = ...;
而且在vc2005下编译运行通过.
后来又需要一个vec4i(成员都为int型的), vec4b(bool型)...
我就定义了一个模版:
template
union v4{
struct { type x,y,z,w;};
type v[4]; //这里出问题了...郁闷
};
本来想之后
typedef union v4 vec4f;
typedef union v4 vec4i;
...
可总是错误
error C2040: 'vect::v' : 'Type [4]' differs in levels of indirection from 'Type'
望各位老大指点小弟.... |