有关数组限制的C ++问题 [英] C++ question about array limit

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

问题描述

在C ++中,如果推操作超出了用于存储库存的数组的大小,会发生什么?

In C++, what happens if the size of the array used to store the stock is exceeded by the push operation?

推荐答案

堆栈溢出"将是提出.

http://en.wikipedia.org/wiki/Stack_overflow [
A "Stack Overflow" will be raised.

http://en.wikipedia.org/wiki/Stack_overflow[^]

When expecting high use of stack you can configure your program to inform the OS to reserve a larger stack. Most languages will give you an option to define the stack size.

Good luck!


发生内存不足异常(不是调用调用堆栈会发生的堆栈溢出,而不是用于将值存储在堆栈中的数组).

为防止这种情况,可以创建堆栈类的自定义实现,该实现使用数组数组存储值.这样,内存碎片将不会阻止创建小型数组.
An out of memory exception occurs (not a stack overflow, which occurs with the call stack, not the array used to store values in a stack).

To prevent this, you can create a custom implementation of the stack class that uses an array of arrays to store values. That way, memory fragmentation will not prevent the small arrays from being created.


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

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