[C++] Stack class using linked list

Questions about programming languages and debugging
Post Reply
User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

[C++] Stack class using linked list

Post by ayu »

Created a Stack class today using the linked list from my previous assignment.

Stack is a form of list which follows the principle of "First in last out" or FILO, if you find it hard to imagine the principle, think of a pile of books where you have to remove the top book to get to the one beneath, and continue to remove books to get to the bottom (assuming that you can not just lift the whole bunch and grab the bottom book, or one in the middle), Stack, follows the same principle.



Linked List

Code: Select all

http://www.suck-oold.com/modules.php?name=Forums&file=viewtopic&t=6453
Stack

Code: Select all

http://code.suck-oold.com/141
The stack class is at the moment poorly commented, and has some unfinished parts, but the parts that are done, works very well. I will finish the rest of the code tonight and update it :)
Last edited by ayu on 12 Feb 2009, 16:39, edited 1 time in total.
"The best place to hide a tree, is in a forest"

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Post by ayu »

Code updated. Some bug fixes applied.
"The best place to hide a tree, is in a forest"

User avatar
Nerdz
The Architect
The Architect
Posts: 1127
Joined: 15 Jun 2005, 16:00
18
Location: #db_error in: select usr.location from sucko_member where usr.id=63;
Contact:

Post by Nerdz »

Code: Select all

#
template<class TemplateItem>
#
bool Stack<TemplateItem>::empty()
#
{
#
        if(mStackList.size() > 0)
#
                return false;
#
        return true;
#
}
:cry: :cry: :cry:

Code: Select all

bool Stack<TemplateItem>::empty()
{
        return mStackList.size() > 0
} 
I've seen this on a lot of other code segment... check it out :wink:
Give a man a fish, you feed him for one day.
Learn a man to fish, you feed him for life.

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Post by ayu »

ah, good find, thanks ^^
"The best place to hide a tree, is in a forest"

Post Reply