linked stack question.

Reply

Join Date: Jun 2005
Posts: 8
Reputation: yaan is an unknown quantity at this point 
Solved Threads: 0
yaan yaan is offline Offline
Newbie Poster

linked stack question.

 
0
  #1
Jun 29th, 2005
I've used linked lists before. Does anybody have a resource or url address on how to write a linked stack? I need to create a stack with a menu using int and char variables.

Thanks.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,039
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 139
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: linked stack question.

 
0
  #2
Jun 29th, 2005
Originally Posted by yaan
I've used linked lists before. Does anybody have a resource or url address on how to write a linked stack? I need to create a stack with a menu using int and char variables.

Thanks.
A stack with a 'menu'? What do you mean by 'menu'?

Creating a linked stack is simple, if you've already written a linked list:

Step 1. Write a linked list.
Step 2. Create a function for pushing an element onto the front of the list. Call this 'push'.
Step 3. Create a function for removing the first element of the list. Call this 'pop'.
Step 4 (optional). Create a function that returns the first element of the list by reference, so it can be used as an lvalue. Call this 'top'.

Viola, you have a linked stack! And of course, with 'function', you can interpret that as 'member function' or 'method': whatever suits you.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 8
Reputation: yaan is an unknown quantity at this point 
Solved Threads: 0
yaan yaan is offline Offline
Newbie Poster

Re: linked stack question.

 
0
  #3
Jun 29th, 2005
what I mean by a menu are choices (1 - push a character/integer, 2 - pop a character/integer, 3 - display all, etc..). I assume I'll be using the switch to accomplish this.

Thanks.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 33
Reputation: shre86 is an unknown quantity at this point 
Solved Threads: 1
shre86 shre86 is offline Offline
Light Poster

Re: linked stack question.

 
0
  #4
Jun 30th, 2005
yeah
the switch statment shud solve all ur probs..
for any source code u want i think the best site is
www.planetsourcecode.com
u ll get everything in tht site..
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC