値は、簡単な方法は
std::array<float, 4> d1; // or float d1[4]
for (int i = 0; i < 4; ++i) d1[i] = i+1.0f;
// or, instead of the loop, since C++11
std::iota(std::begin(d1), std::end(d1), 1.0f); // iota() specified in <numeric>
または(場合、実行時に値が生成されると仮定すると、ある
float d1[4] = {1.0f, 2.0f, 3.0f, 4.0f};
又は
std::array<float, 4> d1 {1.0f, 2.0f, 3.0f, 4.0f}; // since C++11
コンパイル時に知られている場合実行時まで要素の数は分かりません)
std::vector<float> d1(number);
for (int i = 0; i < number; ++i) d1[i] = i+1.0f;
// or, instead of the loop, since C++11
std::iota(d1.begin(), d1.end(), 1.0f);
':: std :: array d1 {1.0f、2.0f、3.0f、4.0f};' –
VTT
[C++で 'malloc'ファミリを使う理由はほとんどありません](https:///stackoverflow.com/questions/44588345/malloc-vs-new-for-primitives/44588567#44588567)。そうしないでください。 – StoryTeller