I am starting to work with Stack in C++. I make the functions for push and pop. When we call the pop function it deletes the top data or info in the stack.
Is it possible to first find the data position in the stack and delete that position’s data?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, the whole point of a Stack is that it’s FIFO, or first-in first-out. Whatever data you push onto the Stack is not accessible until data on top of that has been popped off of the Stack.
If you need to access data underneath the top layer, then you simply need to use another data structure, like an array or a list, for example.
I suggest you spend some time reading about C++ data structures. This will give you a better idea of what each data structure is used for, as well as when you should use a particular data structure. Good luck!