+ 5

In C++ arrays are regarded as evil, why?

C++

22nd Jul 2017, 9:21 PM
Charles Kwaka
Charles Kwaka - avatar
2 Answers
+ 5
They are not safe and secure on their own, you have to manually keep track of their size and they can easily be used to cause buffer overflows and execute malicious code by corrupting the stack. In general it's better to use std::array or other STL containers that suit your need
22nd Jul 2017, 9:29 PM
aklex
aklex - avatar
+ 1
They are not evil, they just don't handle exceptions properly. They are advised to use if you know what you are doing and want maximum performance. Else, it is better to use STL to avoid bugs or exploits in your code.
23rd Jul 2017, 10:12 AM
Denis Felipe
Denis Felipe - avatar