Can you please tell me where I can find every thing about stacks....?
Thank you
Can you please tell me where I can find every thing about stacks....?
Thank you
C++
The best
>Can you please tell me where I can find every thing about stacks....?
The internet, books, and experienced programmers.
-Prelude
My best code is written with the delete key.
Well, you might want to narrow yourself first.
Stack is a word with several meanings.
The first meaning of stack is a concept that dates back to the time when programmers used punch cards. The stack is a conceptual element of your computer's processor that stores data registers. When you call a function at the asm level, your current operations are suspended and said to be "put on the stack," meaning that they are shelved, but put on top, so that when your current function is done, you will go back to where you were before it started.
Stack is also the name of an STL container with similar behavior. A good analogy for an STL stack is a tower of dimes. It is easy to put a dime on top, read the date off of the top dime, or remove the top dime, but it would be difficult to read the date of the bottom dime, or insert a dime in the middle.
Also Prelude, I hate to break it to you, but this is the internet, and you are an experienced programmer.
>Also Prelude, I hate to break it to you, but this is the internet,
>and you are an experienced programmer.
Oh! So that's why people keep asking me questions. Whew, it's nice to have that mystery solved.
-Prelude
My best code is written with the delete key.
Bout time. Now quit jabbering and get back to work.
>Now quit jabbering and get back to work.
What is a stack? A stack is a data structure that is well suited for LIFO type situations where the last item to enter the stack is the first to leave. A good example would be scope levels in a C++ program:
Upon entering main you can consider main to be pushed onto the stack, so it's the only item in our hypothetical example. When the loop is entered, it too is pushed onto the stack because it's a block and has it's own scope. Now you have main at the bottom of the stack and for on top of main. When funcOne is called, it too is pushed onto the stack on top of for. Scope is now in funcOne.Code:// This is our program #include <iostream> using std::cout; void funcOne ( void ) { cout<<"push funcOne\npop funcOne\n"; } int main ( void ) { cout<<"push main\n"; for ( int x = 0; x < 3; x++ ) { cout<<"push for\n"; funcOne(); cout<<"pop for\n"; } cout<<"pop main\n"; return 0; }
When funcOne returns, it is popped off of the stack because it is no longer needed and the scope returns to for. Just to simplify things, I've set it up so that for is popped when each iteration is finished and pushed when an interation starts (my example, my rules, no?). This process occurs three times, for is pushed, funcOne is pushed then popped, and for is popped. When the third iteration completes and the loop is finished, main returns and is popped from the stack. The program is finished. The life of the stack looks like this:
For further illustration please run the program and/or ask for clarification on any point where I was hazy.Code:f1 f1 f1 for for for for for for for for for ---- main main main main main main main main main main main main main ----
-Prelude
My best code is written with the delete key.
Thank you Guys ..........
You are Great...
Look if I find something I will write it here....
C++
The best