```
#include "assign3.h"
#include <iostream>
using namespace std;
Calculator::Calculator(int size) {
if (size > 0) {
mSize = size;
mPstack = mPtop;
if ((*mPstack).im && (*mPstack).re) {
mSize = size;
mPstack = mPtop;
} else {
mSize = 0;
(*mPstack).re = 0;
(*mPstack).im = 0;
}
} else {
mSize = 0;
(*mPstack).re = 0;
(*mPstack).im = 0;
}
int Calculator::size() {
return mSize;
}
Calculator::~Calculator() {
delete mPstack;
}
bool Calculator::push(myComplex x) {
if (mPtop) {
mPtop = &x;
mPtop++;
return true;
} else
return false;
bool Calculator::pop(myComplex& x) {
if (mPtop > mPstack) {
mPtop--;
x.re = (*mPtop).re;
x.im = (*mPtop).im;
return true;
} else{
return false;
}
bool Calculator::oper(char op) {
myComplex sum;
if (mPtop < mPstack + 2)
return false;
int tempRE = (*mPtop--).re;
int tempIM = (*mPtop--).im;
if (op == '/' && tempRE == 0 && tempIM == 0)
return false;
int leftRE = (*mPtop--).re;
int leftIM = (*mPtop--).im;
if (op == '+') {
sum.re = tempRE + leftRE;
sum.im = tempIM + leftIM;
push(sum);
return true;
}
if(op=='/'){
sum.re = leftRE / tempRE;
sum.im = leftIM / tempIM;
push(sum);
return true;
}
return false;
}
```

This is my code. I run for many times . it cannot calculate right answer.

thanks