LNK2019 ссылка на неразрешенный внешний символ

Lib.H

#pragma once

#include <iostream>

using namespace std;

template <class T>
class Array {
private:

    int n;
    T* values;

public:

    Array(int _n = 1, T x = 0); //конструктор с параметрами + по умолчанию
    Array(const Array<T>& other);//конструктор копии 
    ~Array(); // деструктор

    // методы
    int size() const;

    T& operator [] (int i);
    T operator [] (int i) const;

    // дружественные функции
    friend ostream& operator << (ostream& out, const Array<T>& arr);
    friend istream& operator >> (istream& in, Array<T>& arr);
};

template class Array<int>;
template class Array<double>;

Lib.cpp

#include "Lib.h"

template <class T>
Array<T>::Array(int _n, T x)
{

    this->n = _n;
    this->values = new T[_n];
    for (int i = 0; i < n; i++) *(this->values + i) = x;
    cout << "Element created" << endl;

}

template <class T>
Array<T>::Array(const Array<T>& other) {

    this->n = other.n;
    this->values = new T[this->n];
    for (int i = 0; i < n; i++)
    {

        *(this->values + i) = *(other.values + i);

    }
    cout << "Element copyed" << endl;


}

template <class T>
Array<T>::~Array()
{

    this->n = 0;
    delete[] this->values;
    cout << "Delete element" << endl;

}

template <class T>
int Array<T>::size() const
{

    return this->n;

}

template <class T>
T& Array<T>::operator [] (int i)
{

    return *(this->values + i);

}

template <class T>
T Array<T>::operator [] (int i) const
{

    return *(this->values + i);

}

template <class T>
ostream& operator << (ostream& out, const Array<T>& arr)
{

    out << "Size: " << arr.n << endl;
    for (int i = 0; i < arr.n; i++)
    {

        out << *(arr.values + i) << ' ';

    }

    out << endl;

    return out;

}

template <class T>
istream& operator >> (istream& in, Array<T>& arr)
{

    cout << "Size: " << endl;;
    in >> arr.n;
    delete[] arr.values;
    arr.values = new T[arr.n];
    cout << "Elements: " << endl;
    for (int i = 0; i < arr.n; i++)
    {

        in >> *(arr.values + i);

    }

    return in;

}

main.cpp

#include "Lib.h"

int main()
{
    int x = 0;
    Array<int> a = Array<int>(100, x);

    for (int i = 0; i < a.size(); i++) a[i] = i + 1;

    cout << a << endl; // вот здесь возникает ошибка, если закомментировать строчку, все срабатывает. Не пойму, почему, помогите пж

    return 0;

}

Ответы (0 шт):