The problem of dynamic array classes, what is a dynamic array

Updated on technology 2024-05-01
4 answers
  1. Anonymous users2024-02-08

    is a class, and it has two private members, x, y. If you return int, double can only return one, while point can return two or more. It's more convenient, so use a return reference.

    2.Note points, arrayofpoints points, which have a member function element(), element() returns an object of a point, and move() is a member function of point, so it can be called like this.

    Returns the point reference.

    Hope mine can help you!

  2. Anonymous users2024-02-07

    Let's start with the function.

    return points[n]

    Then, one of the points in the array is returned.

    Then, let's look at how points[n] are obtained.

    There was points=new point[n];

    dynamically declare n points of the array and return the first address to points, so.

    The returned value is a member of this array, that is, a point-type one.

  3. Anonymous users2024-02-06

    A dynamic array is an array that is not declared with a certain size of the array, i.e., ignoredSquare bracketssubscript. When used, you can always re-indicate the size of the array with a redim statement (or a malloc statement in C).

    Dynamic arrays, as opposed to static arrays. The length of a static array is predefined and cannot be changed once given a size throughout the program.

    This is not the case with dynamic arrays, which can be resized as needed by the program. The memory space of a dynamic array is allocated from the heap (i.e., dynamically allocated). It is to allocate storage space by performing ** through random searching.

    These statements are assigned when the program executes them. The programmer is responsible for freeing up memory himself. The advantage of using dynamic arrays is that the storage space can be used efficiently according to the user's needs.

    Dynamic Arrays vs. Static Arrays:

    For static arrays, it is very convenient to create, and there is no need to release them after use, and it is easy to reference, but the Achilles heel is that there is no fierce method to change its size after creation.

    For dynamic arrays, they are troublesome to create, and they must be released by the programmer after use, otherwise it will seriously cause memory leaks. However, it is very flexible to use and can be dynamically sized according to the needs of the program.

  4. Anonymous users2024-02-05

    Exactly how big an array should be is sometimes unknown. So I want to be able to have the ability to change the size of the array at runtime.

    Dynamic arrays can be resized at any time. In rent-resistant Visual Basic, dynamic arrays are the most flexible and convenient, which helps to manage memory with shooting effects. For example, you can use a large array for a short period of time, and then, when the array is not in use, free up memory space for the system.

    If you don't use dynamic arrays, declare an array that is as large as possible, and then erase the unnecessary elements. However, if this method is used excessively, it will cause the operating environment of the memory to be slower.

Related questions
17 answers2024-05-01

#include

#include >>>More

21 answers2024-05-01

Dynamic arrays generally have elements, and as long as you use redim, then there must be elements. >>>More

11 answers2024-05-01

The method for dynamically defining a 2-dimensional array in C++ is: >>>More

4 answers2024-05-01

No action is not recorded. It can save space.

8 answers2024-05-01

2D array address - > row address - > column address (variable address) - > variable value, or excerpt a description for you. >>>More