0

I am trying to an Array class with a template and I have a problem.

List.h:

template<class T>
class Array
{
private:
    T** List;
    int Capacity; 
    int Size; 
public:
    Array(); 
    ~Array();
    Array(int capacity);
    Array(const Array<T>& otherArray); 
    int GetSize();
    int GetCapacity();
}; 

And the List.cpp file looks like

#include "List.h"
#include <iostream>
#include <stdio.h>

template<class T>
Array<T>::Array()
{
    printf("Default constructor called!\n");
    Capacity = 0;
    Size = 0;
}

template<class T>
Array<T>::~Array()
{
    delete List;
    Capacity = 0;
    Size = 0;
}

template<class T>
int Array<T>::GetCapacity()
{
    return Capacity;
}

And the main :

int main()
{
    Array<char> A(); //Calling the default constructor
    std::cout << A.GetCapacity();
}

I am calling the default constructor but I don't get anything in the console. I think that I did something wrong with the constructor call or with the constructor declaration.

0 Answers0