在本地C ++向量的内存分配在哪里? [英] Where is the memory for a local C++ vector allocated?

查看:92
本文介绍了在本地C ++向量的内存分配在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到向量的内存是动态分配的。因此,对于本地向量,内存分配在哪里?

I noticed that the memory for vector is allocated dynamically. So for a local vector, where does the memory is allocated?

f(){

 vector<int> vi;
}


推荐答案

堆栈(我的系统上的28个字节)。向量内容在堆上分配。

The vector is allocated on the stack (28 bytes on my system). The vector contents are allocated on the heap.

这篇关于在本地C ++向量的内存分配在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆