push n pop

This is a discussion on push n pop within the C++ Programming forums, part of the General Programming Boards category; can someone briefly explain push and pop with a small simpe program writen in c++ here? if possible, ill be ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    72

    push n pop

    can someone briefly explain push and pop with a small simpe program writen in c++ here? if possible, ill be thankful! please dont direct me to links etc, i want something on which we can discuss here!! thanks

    what's my knowledge about pop / push? all I understood is that pop is used to remove and push is used to add

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You are probably talking about a stack. Perhaps googling the subject of "stack" would help?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248
    or push_back / pop_back from std::vector

    http://www.cplusplus.com/reference/stl/vector/

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Run this code and see if if helps.
    Code:
    #include <iostream>
    #include <stack>
     
    int main()
    {
            std::stack<int> Stack;
     
            for (int i=0; i<10; i++)
            {
                    std::cout << "Pushing: " << i << std::endl;
                    Stack.push(i);
            }
    
            while (!Stack.empty())
            {
                    std::cout << "Popping: " << Stack.top() << std::endl;
                    Stack.pop();
            }
     
            return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. swapping pointers
    By csvraju in forum C Programming
    Replies: 17
    Last Post: 04-01-2009, 03:18 AM
  2. Help calling function is asm
    By brietje698 in forum C++ Programming
    Replies: 24
    Last Post: 12-06-2007, 03:48 PM
  3. Inline asm
    By brietje698 in forum C++ Programming
    Replies: 5
    Last Post: 11-11-2007, 01:54 PM
  4. Getting position from game..
    By brietje698 in forum C++ Programming
    Replies: 1
    Last Post: 10-26-2007, 12:15 PM
  5. Queues
    By ramayana in forum C Programming
    Replies: 22
    Last Post: 01-01-2006, 01:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21