Tuesday, July 28, 2009

Stack as a function parameter in c++?

i'm just learning implementation with stl stacks and queues and i'm not really familiar with them yet. can you make a function that takes an stl stack or queue as a parameter??? if so whats the syntax? the function will take in the stack and push a few values and either return the stack or pass it by reference. is this possible?

Stack as a function parameter in c++?
My opinion would be that it is a normal class / object, and you should be able to pass it as a parameter.





I would be more inclined to pass it as a pointer to the stack, rather than the whole stack itself. Therefore, you would be passing be reference.





I do not think you would have to return the stack, as you could change the contents whilst in this function, and upon returning from the function the stack that you passed as reference would contain the changes made in the function.
Reply:Try google.com and put in stack function. There is an example that you might like.

garden centre

No comments:

Post a Comment