I am getting an error saying this:
error: no matching function for call to 'Expression::shuntingYard(Expression&)'
while the function is declared in the header folder named Expression.h. I can't see what the problem is. I also included all the necessary pre-processor directives.
The following files are included:
main.cpp
#include <iostream>
#include "Expression.h"
using namespace std;
int main()
{
Expression expr("2 * (3 + 1)");
//Set x = 5
//expr.instantiateVariable('x',5);
//Set y = 3
//expr.instantiateVariable('y',3);
cout << "Answer: " << expr.shuntingYard(expr) << endl;
}
Expression.h
#ifndef EXPRESSION_H
#define EXPRESSION_H
#include <string>
#include <iostream>
using namespace std;
class Expression
{
private:
string expression;
public:
Expression(string expr);
~Expression();
void instantiateVariable(char name, int value);
//Function to calculate the postFix string made by the ShuntingYard function
int evaluate(string, int, int);
//Function to convert infix expression to postfix
string shuntingYard(string);
//Other
int higherPrecedence(char operator1, char operator2);
bool IsOperator(char C);
bool IsOperand(char C);
};
#endif
If you can please point out to what I am doing wrong, by receiving this error, I will appreciate it.
Thank you.
Expressiontostd::stringeither.