The use of dynamic arrays in C++builder

Source: Internet
Author: User

Source: Http://i.cnblogs.com/EditPosts.aspx?opt=1

As with the ansistring type, dynamic arrays are defined for compatibility with dynamic arrays in Delphi, where dynamic arrays are used in the form of templates (template), and dynamic arrays are defined as follows:

Template class Delphireturn Dynamicarray;

So we have to specify a definite basic data type when we use it, for example, to define a dynamic array arrayofint of type int, which is defined in the following format:

Dynamicarray Arrayofint;

How do you dynamically change the size of an array? The Dynamicarray class has a property length, so that you can change the size of the array simply by changing the value, for example, to set the length of the Arrayofint to 10:

arrayofint.length=10;

In particular, if you want to release a dynamic array, just set the length to 0, what? Simple enough, huh?

There are not many properties and methods of Dynamicarray, as I will explain below.

high int read-only, upper bound of dynamic array, Length-1.
low int read-only, dynamic array of the lower bound, Huan is 0.
length int set/return the length of the dynamic array, set to 0 to release the array
copy ()   Copy the contents of a dynamic array to another dynamic array, such as Tmp=a_data. Copy (); both must be of the same type.
copyrange (int startindex,int count)   Copy a dynamic array to specify the contents of the range to another dynamic array, the first parameter is the starting position, the second parameter is the number of copies,
=   assigned value. Just generate a variable name that points to this array, and if you want to generate a copy, you must use the copy () method.
==   comparison.
[]   Remove the label.

In this way, we can use dynamic arrays in BCB, and using flexible dynamic arrays in powerful, flexible BCB is not a pleasant thing to do?

Use of dynamic arrays in C++builder (RPM)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.