Question: Consider the following code. In this code the function displayClass ( stackClass ) is called. Which of the following code ( i ) represents the

Consider the following code.
In this code the function displayClass(stackClass) is called.
Which of the following code (i) represents the correct implementation of the DISPLAYCLASS function?
#include
#include //...(i)... missing code for the function.
int main()
{
std::stack stackClass;
stackClass.push("John");
stackClass.push("Peter");
stackClass.push("Mary");
DISPLAYCLASS(stackClass);
return 0;
}
a. void displayClass(std::stack myStack)
{
while (!myStack.empty())
{
std::cout << myStack.top()<<"
";
myStack.pop();
}
}
b. void displayClass(std::stack myStack)
{
while (!myStack.empty())
{
myStack.pop();
std::cout << myStack.top()<<"
";
}
}
c. None of the options provided.
d. void displayClass(std::stack myStack)
{ while (!myStack.empty())
{
std::cout << myStack.top()<<"
";
}
myStack.pop();
}
e. void displayClass(std::stack myClass)
{
myStack = myClass;
while (!myStack.empty())
{
myStack.pop();
std::cout << myStack.top()<<"
";
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!