1
0
mirror of https://github.com/QtExcel/QXlsx.git synced 2025-01-16 04:42:53 +08:00
QXlsx/HelloAndroid/DynArray2D.h
Daniel Nicoletti db608768a3 Add and apply clang-format
This project has no standard on coding style,
some files use tab, others space, and new
Merge Requests usually break the current formatting
with this clang-format we can easy this.
2023-09-14 11:06:39 -03:00

40 lines
737 B
C++

// DynArray2D.h
#ifndef DYNARRAY2D_H
#define DYNARRAY2D_H
// Code from
// https://www.qtcentre.org/threads/31440-two-dimensional-array-size-determined-dynamically Some
// code is fixed by j2doll
template <typename T>
class DynArray2D
{
public:
DynArray2D(int n, int m)
{
_n = n;
_array = new T *[n];
for (int i = 0; i < n; i++) {
_array[i] = new T[m];
}
}
void setValue(int n, int m, T v) { _array[n][m] = v; }
T getValue(int n, int m) { return _array[n][m]; }
~DynArray2D()
{
for (int i = 0; i < _n; i++) {
delete[] _array[i];
}
delete[] _array;
}
protected:
T **_array;
int _n;
};
#endif // DYNARRAY2D_H