Explore BrainMass

Explore BrainMass

    Write a function to create a stack using template in C++

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Write a function

    template <typename T>
    void stackClear (stack<T>& s);

    that clears a stack s. Why is it critical that s be passed by reference?

    Please provide a complete program if it makes sense.

    © BrainMass Inc. brainmass.com December 24, 2021, 6:43 pm ad1c9bdddf

    Solution Preview

    1. Please see the attached file for the function. Basically, popup all the elements in the stack.

    2. Why is it critical that s be ...

    Solution Summary

    The expert creates a stack, and pass parameters by reference.