I'm trying to make a program that changes and compares fields of different documents. There is one base class with virtual functions and some children classes. For convenience I want to put objects of children classes into custom container that represents a linear stack. Here is the header code:
template <class T>
class DocContainer{
public:
    struct ListElement{ // the stack itself
        T obj;
        ListElement *next;
    };
    DocContainer();
    ~DocContainer();
    void pop_top();
    T &get_top() const;
    T &operator[](int);
    void push_top(const T &);
    int size() const;
    void clear();
private:
        ListElement *first;
        int num;
};
I tried to google how to actualize a container for objects of different types and found out that I'm supposed to contain pointers to parent class using the polymorphism. But when I try to use it like this:
Passport *pass = new Passport;
// some code
DocContainer<Document*> DC;
DC.push_top(dynamic_cast<Document*>(pass));
The compiler says:
undefined reference to `DocContainer::push_top(Document* const&)'
Along with the same warnings about constructor and destructor of container.
Class Passport is a child class of Document.
class Passport : public Document{
// some code
};
The push_top() function of container in .cpp file:
template <class T>
void DocContainer<T>::push_top(const T &A){ 
    auto cur = new ListElement;
    cur->obj = A;
    cur->next = first;
    first = cur;
    num++;
    delete cur;
}
There is something surely wrong, but I couldn't find any clear answer. What's the mistake? Thanks in advance
