Creating an Array: Difference between revisions
Content deleted Content added
m →{{header|AppleScript}}: lang tag |
m →{{header|C++}}: lang tag |
||
Line 178:
=={{header|C++}}==
Using dynamically-allocated (i.e. [[Heap]]) memory:
<lang cpp> const int n = 10;
int* myArray = new int[n];
if(myArray != NULL)
Line 186:
delete[] myArray;
myArray = NULL;
}</lang>
Using fixed (i.e. [[System stack|Stack]]) memory:
<lang cpp> int myArray2[10] = { 1, 2, 0}; /* 3..9 := 0 */</lang>
{{libheader|STL}}
<lang cpp> // STL
std::vector<int> myArray3(10);
myArray3.push_back(1);
myArray3.push_back(2);</lang>
{{libheader|Qt}}
<lang cpp> // Qt
QVector<int> myArray4(10);
myArray4.push_back(1);
myArray4.push_back(2);</lang>
{{libheader|MFC}}
<lang cpp> // MFC
CArray<int,int> myArray5(10);
myArray5.Add(1);
myArray5.Add(2);</lang>
=={{header|C sharp|C#}}==
|