Creating a stack class and implementing it with a function