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
}
}
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
Get step-by-step solutions from verified subject matter experts
