Hi all. Just trying to get through this addition portion before moving on with the rest. Can't seem to figure out this pop,pop,push sequence. I know I'm heading in the right direction but can't nail down the exact coding. Any tips?
public:
polishcalc()
{
top = 0;
}
bool isEmpty()
{
return top == 0;
}
int expressionentry(char * userinput)
{
int operand;
polishnode * temp;
char * pch;
pch = strtok (userinput, " ");
while(pch != NULL)
{
if (pch = "+")
{
int operandone;
int operandtwo;
int ans;
if (!isEmpty()) //pop first numerical value
operandone = top->numinput;
delete top;
top->next;
if (!isEmpty()) //pop second numerical value
operandtwo = top->numinput;
delete top;
top->next;
ans = operandone+operandtwo;
top->next = new polishnode(ans,top); //push answer back onto stack
}
else
top = new polishnode(operand,top); //push numerical value until an operator is read