30 std::unique_ptr<Node<NType>>
next =
nullptr;
80 std::unique_ptr<Node<T>> newNode = std::make_unique<Node<T>>();
81 newNode->data = value;
82 newNode->next = std::move(
myTop);
83 myTop = std::move(newNode);
100 if (
myTop)
return false;
114 std::cout <<
"The top element is " << object1.
Top() << std::endl;
This is a template class that represents a single element of a stack, and it will be called "Node".
Definition stack_dsa.hpp:27
std::unique_ptr< Node< NType > > next
Stores the address of the next node.
Definition stack_dsa.hpp:30
Node()=default
Default Constructor.
NType data
Stores the data for each node.
Definition stack_dsa.hpp:29
This is a template class that represents the stack data structure.
Definition stack_dsa.hpp:21
MyStack(const MyStack< T > &)=delete
Deleted copy constructor.
MyStack(MyStack< T > &&other) noexcept=default
Default Move constructor.
std::unique_ptr< Node< T > > myTop
Pointer to the top element of the stack.
Definition stack_dsa.hpp:65
MyStack< T > & operator=(MyStack< T > &&other) noexcept=default
Default Move assignment operator.
virtual T Top()
Returns the top element of the stack.
Definition stack_dsa.hpp:71
MyStack< T > & operator=(const MyStack< T > &)=delete
Deleted copy assignment operator.
virtual MyStack< T > & push_top(const T &value)
Pushes a new element to the top of the stack.
Definition stack_dsa.hpp:79
virtual bool isEmpty()
Returns true if the stack is empty.
Definition stack_dsa.hpp:99
MyStack()=default
Default Constructor.
virtual MyStack< T > & popTop()
Removes the top element of the stack.
Definition stack_dsa.hpp:91