How to manage large buffer in C++?

c++, memory

Solution

How about: 3. Use a vector.

[Edited to add: or boost::array is a good option if you're happy with the dependency]

Problem

If I need a large buffer in my program written in C++, which one is better? Allocate the buffer in heap, and keep a reference to that buffer in the class that use it. Allocate a static buffer, and make it global.

Original source