c++ Vector, what happens whenever it expands/reallocate on stack?

后端 未结 7 755
情深已故
情深已故 2020-11-29 00:51

I\'m new to C++ and I\'m using the vector class on my project. I found it quite useful because I can have an array that automatically reallocates whenever it is necessary (

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 01:34

    The vector object may well be instiantiated on the stack but the data within the vector will be on the heap.

    (The trivial class class foo {int* data;}; has this characteristic)

提交回复
热议问题