How would you like to MASTER graphic design by next week?
Click here to find out how
Featured Photoshop templates - professional ready to use designs for your next project
View all templates
C++ Stack Tutorials
Simple Stacks! A Gentle Approach
Welcome to my Simple Stacks tutorial! By all means, this is not the best nor greatest implementation but I'm sure you'll learn something new if you're just starting out. I also acknowledge I could have done a lot cooler looking stuff in C++ but that's just boring.
This tutorial specifies understanding of the stack and code of stack.
ADTs: Stacks and Queues Part 1: Using Arrays
Learn about and how to use ADTs: Stacks and Queues in C++.
ADTs: Stacks and Queues Part 2: Using Lists
Learn about and how to use ADTs: Stacks and Queues for C++ Part 2.
Sequental Lists The Queue and Stack Class With C#
Sequential lists are collection of objects that can be entered or extracted in a sequential way. They don’t provide access to objects in the middle on the list. You can only access a specific object each time you extract it. The two classes named “Queue” and ”Stack” which belong to the “System.Collections” namespace provide you with this kind of functionality, each of them in a slightly different way. The Queue class offers you access to the first object on the list, whereas the Stack class offers you access to the last object on the list. By first and last we mean the first and last object that entered the list. So, the Queue class is a First-in, First-out collection(FIFO Collection) whereas the Stack class is a Last-in, First-out(LIFO Collection). In this tutorial you will create and use both classes to see how they behave when entering and extracting data. You will usually work with such collections with temporary and disposable data. For a more permanent use, arrays provide much better functionality.
Value Data Types
C# distinguishes between two (2) different data types categories: value and reference types. Value data types directly store their value while reference data types store a reference to their value. Value types are stored on the stack whereas reference types are stored on the managed heap.
STRUCTS In C#
Structs, similar to classes, are used to define various objects in your code. They are stored on the stack, rather than in the managed heap. This means that they are value-type objects and thus, when you pass a struct as a parameter in a function, a copy of the object is actually passed to that function. This can affect the performance of your code if you use structs for large objects. However, since the .Net does not bring in the managed heap, structs are more suitable for small objects of limited functionality and with no inheritance capabilities.
Reference Data Types
Reference types provide excellent flexibility and performance of large structures. This is the reason that classes are reference types and structs are data value types. As you will probably know, reference types do not store the actual value of the object but a pointer to a memory location. This pointer is stored on the stack whereas the object itself is located in the managed heap.
Garbage Collection In C#
A significant advantage of C# when compared to C++ is the memory management capabilities of the C#. The programmer need not worry about memory management; the garbage collector is assigned this operation on the programmer’s behalf. You will probably know that value data types are stored on the stack while reference data types are stored on the managed heap. The stack stores data value types that are not members of objects. Also, in C# it is always the case that if variable a goes into scope before variable b, then b will go out of scope first. For example, if you declare some variables in a method, these variables will go out of scope when the method ends. However, it maybe sometimes that you need to keep these variables long after the method/function ended. This happens for all data declared with the new operator, the reference types. All reference types are stored in the managed heap, which is under the control of garbage collector.
Lesson 18: Pointers and Stacks in C
Today's lesson goes more into details about pointers and their usage as function's arguments. Additional tutorial about stacks in C and C++ is provided. Be sure to read this lesson carefully in order to understand it, since pointers are most important part of C programming language.