3

What is the difference between the direct assignment of an array vs assigning a struct that contains an array, except the fact that the former doesn't compile? Is there any reason that it doesn't work? Isn't the latter a hack, or is it fine to use it?

float naked_array[5];

struct Foo {
  float array[5];
};

int main() {
  // Doesn't compile:
  naked_array = {1, 2, 3, 4, 5};

  // Compiles fine:
  Foo f;
  f = {1, 2, 3, 4, 5};
}
Jojolatino
  • 696
  • 5
  • 11

0 Answers0