template <class T>
bool newArray(T *&Array, int num)
{
if (num > 0)
{
Array = new T[num];
}
else
{
std::cout << "num<1" << endl;
return false;
}
assert(Array != nullptr);
return true;
}
template <class T>
bool deleteArray(T *&Array, int num)
{
assert(Array != nullptr);
delete[num] Array;
Array = nullptr;
return true;
}
template <typename T>
bool newArray(T ***&Array, int rows, int cols, int angle)
{
if (!((rows >= 1) && ((cols >= 1) && (angle >= 1))))
{
std::cout << "rows<1 OR cols<1 OR angle<1" << std::endl;
return false;
}
Array = new T **[rows];
for (int i = 0; i < rows; ++i)
{
Array[i] = new T *[cols];
for (int j = 0; j < cols; ++j)
{
Array[i][j] = new T[angle];
}
}
assert(Array != nullptr);
return true;
}
template <typename T>
bool deleteArray(T ***&Array, int rows, int cols, int angle)
{
assert(Array != nullptr);
for (int i = 0; i < rows; ++i)
{
for (int j = 0; j < cols; ++j)
{
delete[angle] Array[i][j];
Array[i][j] = nullptr;
}
delete[cols] Array[i];
Array[i] = nullptr;
}
delete[rows] Array;
Array = nullptr;
return true;
}
template <typename T>
bool newArray(T **&Array, int rows, int cols)
{
if (!((rows >= 1) && (cols >= 1)))
{
std::cout << "rows<1 OR cols<1" << std::endl;
return false;
}
Array = new T *[rows];
for (int i = 0; i < rows; ++i)
{
Array[i] = new T[cols];
}
assert(Array != nullptr);
return true;
}
template <typename T>
bool deleteArray(T **&Array, int rows, int cols)
{
assert(Array != nullptr);
for (int i = 0; i < rows; ++i)
{
delete[cols] Array[i];
Array[i] = nullptr;
}
delete[rows] Array;
Array = nullptr;
return true;
}