0

Hi can you help me. I was assigned to create a stack in c++ and my professor asked to put arrays inside each stack. how do i do that?

3
Contributors
3
Replies
11
Views
1 Year
Discussion Span
Last Post by rubberman
0

We don't do your homework for you. Try to solve the homework problem and if you are still having difficulties then post your code here.

0

Welcome to Daniweb.

Please note that the first part of any solution process is to get a clear and complete understanding of the problem.

So, are you sure of:

... I was assigned to create a stack in c++ and my professor asked to put arrays inside each stack ... ?

Note: It is quite common to 'use an array' as the container for a 'stack'.

Note too that a C++ vector container is really just an easily expandable dynamic array that has added push_back, (read) back and pop_back methods (functions).

So ... since a stack is a LIFO (last in first out) type of container structure ... any container that has 'push_back', '(read) back' and' pop_back' methods (functions) could be used for a stack ... (and/or push_front, (read) front, pop_front).

This is why a C++ list is also often used as a container to code a stack.

Make you best efforts to code a solution to your problem ... but firstly ... make sure that you have a clear and complete statement of that problem.

If you need help to understand that 'statement' ... you will also need to include the exact statement of the problem as it was given.

Edited by David W

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.