Dynamic arrays

Top  Previous  Next

What is translated > Types > Arrays > Dynamic arrays

 

C++ Builder

 

Dynamic arrays are simulated in the C++Builder C++ by the class

 

template<class T>

using D2CArray = System::DynamicArray<T>;

 

This class is defined in d2c_array.h

 

Remark:

 

The simpler definition

 

template <class T> class DELPHIRETURN DynamicArray;

 

is not resolved correctly by C++Builder, if the generic TArray<T> class is in scope.

 

 

Portable

 

If the output is generated for other compilers std::vector is used instead of a DynamicArray.

 

MyFlexibleArray: array of Real;

->

DynamicArray < double > MyFlexibleArray;  // C++Builder

std::vector < double > MyFlexibleArray;   // other compiler 

 

 

This DynamicArray class has the properties Low, High and Length. By the Length property, the size of the array can be changed. Dynamic arrays are accepted as parameters only, if the type of the array is defined explicitly and if the function expects this type.

 

 

 



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content