我有下一个类,想要用0:
初始化_operators数组 //Entity.h
class Entity
{
static const unsigned short operatorTypeColumn = 1;
static const unsigned short outputValueColumn = 4;
private:
mainDataType _operators[operatorsMaxCount][operatorsTableWidth];
}
//Entity.cpp. I thought this should work in C++ v11
Entity::Entity(void) : _operators[operatorsMaxCount][operatorsTableWidth]
{
}
我认为这是在C ++ v11中出售的工作,但是我得到了错误...我怎么能用0来初始化数组..丑陋的?我不想让它静止
答案 0 :(得分:6)
您只需要对数组进行值初始化:
Entity::Entity() : _operators() {}
// ^^
这适用于C ++ 03和C ++ 11。