Struct Array Error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Struct Array Error

https://code.sololearn.com/cC5fHLfx39Zs/?ref=app It gives me an error about the "flexible array" in an "otherwise empty struct" Why? What can I do to fix this? What's the easiest way to initialize an array through a constructor?

21st May 2018, 2:34 PM
fallOut015
fallOut015 - avatar
7 Answers
+ 3
An additional T* contents; ?
21st May 2018, 2:52 PM
Timon Paßlick
+ 2
: contents(arg) Does this work?
21st May 2018, 2:50 PM
Timon Paßlick
+ 2
That worked because unlike in C, [arrays] need a size which is known at compile time. Otherwise, you can make them a pointer, or, even better: use the std::vector class. Google that up if you want to, they're better at explaining than me.
21st May 2018, 2:57 PM
Timon Paßlick
+ 2
Perfect.
21st May 2018, 2:58 PM
Timon Paßlick
21st May 2018, 2:51 PM
fallOut015
fallOut015 - avatar
21st May 2018, 2:54 PM
fallOut015
fallOut015 - avatar
0
Timon Paßlick I've heard of the vector
21st May 2018, 2:57 PM
fallOut015
fallOut015 - avatar