C ++支持可变长度数组? [英] Does C++ support Variable Length Arrays?

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

问题描述

不,等待,忍受我...

No, wait, bear with me...

VLA始终是GCC扩展,但它们被C99采用:

VLAs were always a GCC extension, but they were adopted by C99:


[C99:6.7.5.2/4]:如果大小不存在,数组类型是
不完整类型。如果大小是*而不是一个表达式,
数组类型是一个未指定大小的变量长度数组类型,其中
只能用于函数原型作用域的声明;这样的
数组仍然是完整的类型。 如果大小是整数
常量表达式,且元素类型具有已知的常量大小,

数组类型不是可变长度数组类型; 否则,
数组类型是一个变长数组类型。

[C99: 6.7.5.2/4]: If the size is not present, the array type is an incomplete type. If the size is * instead of being an expression, the array type is a variable length array type of unspecified size, which can only be used in declarations with function prototype scope; such arrays are nonetheless complete types. If the size is an integer constant expression and the element type has a known constant size, the array type is not a variable length array type; otherwise, the array type is a variable length array type.

ISO / IEC 9899:1999

现在:


[C ++ 11:1.1 / 2]: C ++是一种基于通用编程语言的
在ISO / IEC 9899:1999
(以下简称C标准)中规定的C编程语言。除了C提供的
设施外,C ++还提供了
额外的数据类型,类,
模板,异常,命名空间,操作符重载,函数名
重载,引用,管理运营商和
额外的图书馆设施。

[C++11: 1.1/2]: C++ is a general purpose programming language based on the C programming language as specified in ISO/IEC 9899:1999 (hereinafter referred to as the C standard). In addition to the facilities provided by C, C++ provides additional data types, classes, templates, exceptions, namespaces, operator overloading, function name overloading, references, free store management operators, and additional library facilities.

推荐答案

这个余地的措辞并不意味着C99中的任何东西都是C ++ 11。您所引用的只是介绍性文字。

That leeway wording doesn't mean that any and everything in C99 is in C++11. What you quoted is just introductory text.

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

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