Hi, can u help me with this code below
Code:#pragma warning(disable:4786)
#include<iostream>
#include<string>
#include<stack>
using namespace std;
void displayStack( std::stack<string> aStack ) //by value
{
for( ; !aStack.empty(); aStack.pop() )
{
std::cout<<"Expression entered:"<<aStack.top()<<"\n";
}
}
typedef stack<string> stackMain;
int main()
{
stackMain stack1;
std::string str;
//add item into stack 1
cout<<"Insert any an expression: ";
cin>>str;
stack1.push(str);
displayStack(stack1);
return 0;
}
when i entered an expression such as 1 + 2, the output will be 1 + 2 but the stack size is 1. I expected the stack size to be 3. are there ways to make the stack size into 3 ??