Sunday, October 30, 2005

stack usage

This shows the allocation and de-allocation of space in a stack

 

 

#include <stack>

class X {};

int main() {

   std::stack<X*> mystack;

   X * tmp = new X;

   mystack.push(tmp);

   tmp = mystack.top();

   mystack.pop();

   delete tmp;

   return 0;

}

 

 

 

Pradyut
http://pradyut.tk
http://spaces.msn.com/members/oop-edge/
http://groups-beta.google.com/group/oop_programming
India

 

No comments: