Question: ` ` ` } / / Implementation for the MathStack class / / * * * * * * * * * * * *

```
}
// Implementation for the MathStack class
//*******************************************************
// Member function add. add pops
// the first two values off the stack and
// adds them. The sum is pushed onto the stack.
//***************************************************
void MathStack::add()
{
int num, sum;
// Pop the first two values off the stack.
pop(sum);
pop(num);
// Add the two values, store in sum.
sum += num;
// Push sum back onto the stack.
push(sum);
}
``````
//**********************************************************
// Member function sub. sub pops the *
// first two values off the stack. The *
// second value is subtracted from the *
// first value. The difference is pushed *
// onto the stack.
//******************************************************
void MathStack::sub()
{
int num, diff;
// Pop the first two values off the stack.
pop(diff);
pop(num);
// Subtract num from diff.
diff -= num;
// Push diff back onto the stack.
push(diff);
}
// TO DO 4: Add below the implementation for the multiply function
```
` ` ` } / / Implementation for the MathStack

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 Programming Questions!