Проблема с template

#include <iostream>
using namespace std;

template<typename T>
class List 
{
public:
    List();
    void push_back(T data);
    void pop_back(T data);
    template<typename A>
    void lout(List<A>& lst);
    template<typename A>
    void lin(List<A>& lst);
    int GetSize() {return Size;}
    T& operator[](const int index);
        template<typename T>
        class Node {
        public:
            Node *pNext;
            T data;
            Node(T data = T(), Node *pNext = nullptr) {
                this->data = data;
                this->pNext = pNext;
            }
        };
        int Size;
        Node<T> *Top;
};

template<typename T>
List<T>::List() {
    Size = 0;
    Top = nullptr;
}

template<typename T>
void List<T>::push_back(T data) {
    if (Top == nullptr) {
        Top = new Node<T>(data);
    }
    else {
        Node<T> *current = this->Top;
        while (current->pNext != nullptr) {
            current = current->pNext;
        }
        current->pNext = new Node<T>(data);
    }
    Size++;
}

template<typename T>
void List<T>::pop_back(T data) {
    if (this->Top != nullptr) {
        delete this->Top;
    }
}

template<typename T>
template<typename A>
void List<T>::lout(List<A>&lst) {
    cout << "Our list: ";
    for (int i = 0; i < Size; i++) {
        cout << lst[i] << " ";
    }
}

template<typename T>
template<typename A>
void List<T>::lin(List<A>& lst) {
    cout << "How many times do you want to input some data? Please do not enter other data type" << endl;
    int answer;
    cin >> answer;
    T input;
    for (int i = 0; i < answer; i++) {
        cin >> input;
        lst.push_back(input);
    }
}
template<typename T>
T& List<T>::operator[](const int index)
{
    int counter = 0;
    Node<T>* current = this->Top;
    while (current != nullptr) {
        if (counter == index) {
            return current->data;
        }
        current = current->pNext;
        counter++;
    }
}
template<typename T>
int main() {
    List<T> lst;
    lst.lin(lst);
    lst.lout(lst);
    lst.pop_back(lst);
    lst.lout(lst);
    return 0;
}

Появляется ошибка, когда в методах lin и lout пытаешься сделать тип данных A. То есть я хочу вводить данные с клавиатуры, не привязывая их к определённому типу.


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