Should arrays be used in C++?

Andreas picture Andreas · May 23, 2012 · Viewed 20.3k times · Source

Since std::list and std::vector exist, is there a reason to use traditional C arrays in C++, or should they be avoided, just like malloc?

Answer

Sergey Kalinichenko picture Sergey Kalinichenko · May 23, 2012

In C++11 where std::array is available, the answer is "yes, arrays should be avoided". Prior to C++11, you may need to use C arrays to allocate arrays in the automatic storage (i.e. on the stack).