I am learning data structures and algorithms. My teacher told me the following:
push(): push inserts an element in the stack
pop(): pop deletes the last inserted element from the stack
size(): Returns the number of elements in the stack
isempty(): Returns a boolean indicating if the stack is empty
top(): returns the top element of the stack, without removing it; If stack is empty an error is returned.
Where are the implementations of these functions? Are these built-in functions of C++?
Your teacher was explaining the functions available for the generic stack data structure. Those functions aren’t implemented anywhere in particular because your teacher was not talking about any specific stack. Your teacher wasn’t even talking about C++. Right now you’re just learning about what a stack is: they’re abstract data structures implementable in any language. They’re last-in-first-out containers. Later in your course, you’ll learn about trees, queues, heaps, lists, and all sorts of other abstract data structures. In a later lesson, your teacher will probably demonstrate how to implement the functions listed above. The demonstration might even be in C++.