I am having troubles instantiating an object of a template class type in C++.
Here is the code:
Array.h:
//Developed by Trofimov Yaroslav on 30.03.2018
#ifndef _ARRAY_H_TROFIMOV_
#define _ARRAY_H_TROFIMOV_
template<size_t n, typename T>
class Array
{
static unsigned __freeId, __quantity;
unsigned _id;
T* _array;
public:
template<size_t n, typename T>
Array(void);
~Array(void);
T& operator[](const size_t);
};
#include "Array.cpp"
#endif
Array.cpp:
//Developed by Trofimov Yaroslav on 30.03.2018
#include "Array.h"
template<size_t n, typename T>
Array::Array(void)
: _id(++__freeId), _array(new T[]) {
}
template<size_t n, typename T>
Array::~Array(void) {
}
template<size_t n, typename T>
T& Array::operator[](const size_t i) {
}
Main.cpp:
//Developed by Trofimov Yaroslav on 30.03.2018
#include <iostream>
#include "Array.h"
int main(void) {
Array<7, int> a;
return 0;
}
Now when I hover over a
in Main.cpp
I see the following:
Error: no default constructor exists for class "Array<7U, int>"
But as you can see, the default template constructor does exist. So, what am I missing here?