Convert int* to int error for stack as a linked list

  c++, linked-list, stack
     
    template <class Type>
         Type stackType<Type>::top() const {
             assert(stackTop != nullptr);  // if stack is empty, terminate the program

             return stackTop->list;  // return the element of the stack 
         }

Error:

stackTypeY.h: In instantiation of ‘Type stackType::top() const [with Type = int]’:
testStack.cpp:22:31: required from here
stackTypeY.h:129:22: error: invalid conversion from ‘int*’ to ‘int’ [-fpermissive] return stackTop->list; // return the element of the stack

Source: Windows Questions C++

LEAVE A COMMENT