Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double resolve(double op, double a, double b) {
- char s = static_cast<char> (op);
- switch (s) {
- case '+': return a + b;
- case '-': return a - b;
- case '/': return a / b;
- case '*': return a * b;
- case '^': return pow(a,b);
- }
- }
- double result() {
- stackClass s;
- double a, b;
- node tmp, r;
- while (!postfix.empty()) {
- tmp = postfix.pop();
- if (tmp.isOperator()) {
- b = s.pop().data;
- a = s.pop().data;
- r = node(resolve(tmp.data, a, b));
- s.push(r);
- } else {
- s.push(tmp);
- }
- }
- return s.pop().data;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement