w******g 发帖数: 67 | 1 Hi all,
I want to define one const static vector type member with some initial
value, for example:
const static int array[12] = {-413, -423, -415, -1016, -1026, -417, -411, -
412,
-215, -217, -211, -212};
class VP1TriggerMuonBase
{
public:
const static std::vector pad_exception(array, array+12);
}
But the compiling failed with error. Could anybody correct me? | k****f 发帖数: 3794 | 2 不能在定义类的时候,给成员变量初始化的。
【在 w******g 的大作中提到】 : Hi all, : I want to define one const static vector type member with some initial : value, for example: : const static int array[12] = {-413, -423, -415, -1016, -1026, -417, -411, - : 412, : -215, -217, -211, -212}; : class VP1TriggerMuonBase : { : public: : const static std::vector pad_exception(array, array+12);
| t****t 发帖数: 6806 | 3 actually, you can. but only for integral type (or enumeration); initializer
must be const.
otherwise, must initialize it when you define it.
【在 k****f 的大作中提到】 : 不能在定义类的时候,给成员变量初始化的。
|
|