I have a dynamic template array as a member of my class. However, I can't resize the array in the constructor or in any other functions. I'm confused on the syntax. Here's the code:
template <class Type> class MaxHeapTree {
private:
HeapNode<Type> *array[];
HeapNode<Type> *root;
int elementSize;
int height;
int leafCounter;
public:
// Constructor
MaxHeapTree(int n = 10) : elementSize(0), height(0), leafCounter(0) {
HeapNode<Type> *array = new HeapNode<Type>[n];
}
The array is a an array of HeapNode<Type>
objects included from the HeapNode class. Here's the constructor for the HeapNode class:
template <class Type> class HeapNode {
private:
int key;
Type value;
public:
HeapNode(int key, Type const &value) {
this->key = key;
this->value = value;
}