Write a friend function that can examine the elements


Question: Write a function that compares two stacks for equality. The function takes two stacks as parameters and returns true if they are identical. The stacks should remain unchanged after the function returns to the calling program.

Case 1: Write a friend function that can examine the elements directly, or pop the stacks and save the popped elements so that the stacks can be restored.

Case 2: In this second case, the stack parameters will not be const reference parameters because they are temporarily changed before being restored. As an alternative, the parameters could be value parameters (so that changing them does not affect the actual arguments).

Q: Which of the three approaches (friend function, reference parameters, or value parameters) will be most efficient?

Q: For any of your stack implementations, please write a new member function called flip with no parameters. After a stack x activates flip, x should contain the same items, but the order of those items has been reversed.

Please keep it short and simple and no copy and paste or help me to get started.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Write a friend function that can examine the elements
Reference No:- TGS0945569

Expected delivery within 24 Hours