C++ (Vectors & Arrays) (doubles & floats)? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

C++ (Vectors & Arrays) (doubles & floats)?

Why would we use arrays than vectors? Aren't vectors better to use, and is more useful? What about doubles, and floats? Why would we need floats, only accurate at 6 digits after the decimal then doubles, about 16 accurate digits after the decimal? Can someone explain?

28th Jan 2017, 3:34 AM
Dawzy
Dawzy - avatar
2 Answers
+ 1
In general I would use vectors and doubles. Arrays can be used to avoid heap allocations since they can be allocated on the stack. Floats use half the memory, so they provide a trade-off between precision and space.
28th Jan 2017, 4:09 PM
Igor B
Igor B - avatar
0
I see, thanks.
29th Jan 2017, 5:34 AM
Dawzy
Dawzy - avatar