A
A
alexandrfefelov2014-05-18 17:34:23
C++ / C#
alexandrfefelov, 2014-05-18 17:34:23

Is it possible to add rows to a 2D dynamic array after it has been declared?

C++, declared din. 2-dimensional array with coordinates of points and values. functions in them (x, y, f). If a new dot appears - can I add another line?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
L
lookid, 2014-05-18
@lookid

struct Point {
float x, y, f;
}

std::vector<Point> points;

A
AxisPod, 2014-05-18
@AxisPod

No, you can’t, you need to re-allocate the array of the required size, copy it from the old one, delete the old one, add the necessary records.
Or use stl containers.

A
Andrey Vershinin, 2014-05-18
@WolfdalE

If it's a simple array, then no.

A
alexandrfefelov, 2014-05-18
@alexandrfefelov

ArrIn = new float*[pointsIn];                               //строк в массиве
for (int i=0; i<pointsIn; i++) ArrIn[i] = new float[3];     //три столбца

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question