#ifndef DOUBLEARRAY_H
#define DOUBLEARRAY_H

#include <cassert>
//  template <typename T>

class DoubleArray   // Array
{
private:
    int m_length{};
    double* m_data{}; //T*

public:

    DoubleArray(int length)
    {
        assert(length > 0);
        m_data = new double[length]{};  //double -> T
        m_length = length;
    }

    DoubleArray(const DoubleArray&) = delete;
    DoubleArray& operator=(const DoubleArray&) = delete;

    ~DoubleArray()
    {
        delete[] m_data;
    }

    void erase()
    {
        delete[] m_data;
        // We need to make sure we set m_data to 0 here, otherwise it will
        // be left pointing at deallocated memory!
        m_data = nullptr;
        m_length = 0;
    }

    double& operator[](int index) //double -> T
    {
        assert(index >= 0 && index < m_length);
        return m_data[index];
    }

    int getLength() const { return m_length; }
};

#endif

#include <iostream>
#include "Array.h"

using namespace std;

int main()
{
	const int length = 12;
	Array<int> intArray { length };
	Array<double> doubleArray { length };

	for (int count = 0; count < length; ++count)
	{
		intArray[count] = count;
		doubleArray[count] = count + 0.5;
	}

	for (int count = length - 1; count >= 0; --count)
		cout << intArray[count] << '\t' << doubleArray[count] << '\n';

	return 0;
}