Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
doc_src_qvarlengtharray.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
5int myfunc(int n)
6{
7 int table[n + 1]; // WRONG
8 ...
9 return table[n];
10}
12
13
15int myfunc(int n)
16{
17 int *table = new int[n + 1];
18 ...
19 int ret = table[n];
20 delete[] table;
21 return ret;
22}
24
25
27int myfunc(int n)
28{
30 ...
31 return array[n];
32}
34
35
38int *data = array.data();
39for (int i = 0; i < 10; ++i)
40 data[i] = 2 * i;
QVarLengthArray< int > array(10)
[2]
int myfunc(int n)
[0]
return ret
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat n
GLenum array
GLenum GLenum GLsizei void * table