Arrays in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Arrays in c++?

Ok, I was under the impression that arrays in c++ must have their size declared upon compile time. I was specifically told that I wouldn't be able to do this. Why does this code work? Were they wrong? https://code.sololearn.com/cf84ULuaG3Nc/?ref=app

30th Jan 2019, 10:32 AM
Daniel Cooper
Daniel Cooper - avatar
2 Answers
+ 3
Did ask myself this question a while ago, thankfully a friend enlightened me that although this was possible, such ways ideally should be paired with use of dynamic array or std::vector. IIRC such declaration of array isn't all too widely supported (compatible) with the most compilers family, if I understood correctly what my friend told me, that is : )
30th Jan 2019, 11:19 AM
Ipang
+ 2
30th Jan 2019, 11:50 AM
HonFu
HonFu - avatar