0

I am trying to make a stack of linked lists and I am running into a error

Here is my deconstructor:

template <typename T>
mystack<T>::~mystack()
{
    node_type* temp;
    while (pTop != nullptr) {
        temp = pTop;
        pTop = pTop->getNext();
        delete temp;
    }
}

The error is being thrown when I call this function

double process_line(std::istream& input) {


DS::mystack<double> stack;
            //std::cout << stack.size();

    if (isdigit((input.get()))) {
        //stack.push(input.get);
    }
    else {

    }

    return 0;
}

When I don't create a new stack I don't get the error but when I do I get this error code Severity Code Description Project File Line Suppression State

Error   LNK2019 unresolved external symbol "public: virtual __thiscall DS::mystack<double>::~mystack<double>(void)" (??1?$mystack@N@DS@@UAE@XZ) referenced in function "public: virtual void * __thiscall DS::mystack<double>::`scalar deleting destructor'(unsigned int)" (??_G?$mystack@N@DS@@UAEPAXI@Z)  lob06   C:\Users\name\source\repos\lob06\processline.obj    1   

Any help would be appreciated.

  • @Yksisarvinen if templates can only be implemented in headers how can I create a stack in a seperate cpp – Aanom123 Apr 01 '20 at 22:12
  • 1
    By including that header file. The variable definition `mystack some_stack;` is separate from the definition of the class template `template class mystack`. – Some programmer dude Apr 01 '20 at 22:14

0 Answers0