我设置了一类:定义静态二维数组与内联函数
class Example {
static const float array[3][8];
};
实施
inline const float below_center(const float pos) {
return pos - (size/2); // size is a const float
}
inline const float above_center(const float pos) {
return pos + (size/2);
}
inline const float *set_pos(const float x, const float y) {
return (float []) {
below_center(x), below_center(y),
below_center(x), above_center(y),
above_center(x), below_center(y),
above_center(x), above_center(y),
};
}
const float Example::array[3][8] = {
set_pos(2.0f, 0.0f),
set_pos(-1.0f, -1.0f),
set_pos(1.0f, -1.0f),
};
但是当我这样做,我得到一个错误说,“'常量浮动*'到'初始化中的'const float'“。我明白错误在说什么,但是它是在说'const float',以及如何使用细分的内联函数来实现我的数组。
使用内联的全部要点是避免使用宏。那么内联的内容是什么? – NebulaFox 2010-09-13 18:48:30