void myfunction(const std::stack<int>& foo)
{
// use 'foo' here
}
int main()
{
std::stack<int> yam;
myfunction( yam );
}
That passes by 'const reference'. 'foo' cannot be modified by that function.
You can also pass by non-const reference (std::stack<int>& foo). If you do that, any changes you make to foo will be visible in 'yam'.
You can also pass by value (std::stack<int> foo). If you do that, foo is a copy of the yam. You can modify it, but changes will not affect yam. Passing by value can be expensive for complex objects like stacks/maps.