Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

Differentiate the function. r(z) = 2-8 - 21/2 r'(z) =

Answered: 1 week ago