1
我該如何初始化一個靜態成員變量「動態」?如何初始化一個靜態成員變量「動態」?
舉例來說,我宣佈在類的頭文件,這個變量:
class MyPermutation {
static std::array<std::vector<uint8_t>,2> permutation_list;
};
而且我希望它有以下值:
permutation_list[0] = std::vector<uint8_t>{0};
permutation_list[1] = std::vector<uint8_t>{};
for (uint8_t i = 0; i < 8; i++)
permutation_list[1].push_back(1<<i);
我應該在哪裏把上面的代碼?
也許能幫助:http://stackoverflow.com/questions/1197106/static-constructors-in-c-need-to-initialize-private-static-objects – codeling