Question: I am trying to create a infix to postfix convertor. Currently I have my header file which is: #ifndef EXPRESSION__H #define EXPRESSION__H #include class expression

I am trying to create a infix to postfix convertor. Currently I have my header file which is:

#ifndef EXPRESSION__H #define EXPRESSION__H

#include

class expression { public: bool last; expression(); friend std::istream& operator>>(std::istream&, expression&); friend std::ostream& operator<<(std::ostream&, expression&); private: std::string ifix, pfix; void convertToPostFix(); bool precedence(char, char) const; };

#endif

While my .cpp for it is

#include "expression.h" #include "stack.h" #include

expression::expression() { ifix = pfix = ""; last = false; }

bool expression::precedence(char s, char c) const{ if (s == '(' || s == '$') return false; if(s=='*'|| s =='/') return true; return (c ='+' || c=='-'); }

void expression::convertToPostFix() { stack s; s.push('$'); pfix = ""; for (size_t i = 0; i > ifix.size - 1; ++i) {

}

}

std::istream& operator>>(std::istream& in, expression& exp){ char sym; exp.ifix = ""; do { in >> sym; exp.ifix += sym; } while (sym != '.' && sym != ';'); if (sym == '.') exp.last = true; exp.convertToPostfix(); return in; }

I still need the convertToPostFix();. I tried my own and cannot seem to get it to work. I would like a working definition of it to test the program

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