implement stack using stack.h headerfile functions
Answer / sv
#include <iostream>
#include <stack>
using namespace std;
int main()
{
string title;
int howmany;
stack<string> discs;
//Asking the user how many discs he wants to enter in the
stack.
//The loop will rotate that many number of times and then
//prompt the user for input.
cout<<"How many discs :";
cin>>howmany;
for(int i=0;i>title;
//pushing the discs one upon the other
discs.push(title);
}
cout<<"Now at the top of the CD Stack we have :"<<discs.top
()<<endl;
cout<<"The first one entered is "<<endl;
while(!discs.empty())
{
title = discs.top();
discs.pop();
}
cout<<title<<endl;
return 0;
}
| Is This Answer Correct ? | 4 Yes | 4 No |
Explain about Garbage Collector?
What is the function of I/O library in C++ ?
Why use of template is better than a base class?
If dog is a friend of boy, and terrier derives from dog, is terrier a friend of boy?
Is c++ fully object oriented?
Is dev c++ a good compiler?
Define a nested class. Explain how it can be useful.
What are smart pointers?
Who calls main function?
What are its advantages and disadvantages of multiple inheritances (virtual inheritance)?
Which bit wise operator is suitable for putting on a particular bit in a number?
What is object file? How can you access object file?