推送数组C ++? [英] PUSH an array C++?

查看:60
本文介绍了推送数组C ++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何动态地向数组添加值(推)?我可以在AS3中做到这一点,但在C ++中找不到它的功能.

How would I dynamically add a value (push) to an array? I could do this in AS3, but I can't find a function for it in C++.

推荐答案

如果它是像这样的静态定义的数组,则不能:

You can't if it's a statically defined array like so:

int array[10];

它的大小是固定的.但是,如果您使用诸如std::vector之类的容器,则会使用:

Its size is fixed. However, if you use a container such as std::vector you'd use:

std::vector::push_back()

这篇关于推送数组C ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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