I'm currently working on a project to convert from postfix to infix using a stack implemented through a linked list. I'm trying to take in a line and then pushing each character onto a stack however I keep getting the error.
Error: invalid user-defined conversion from ‘char’ to ‘const stack_element& {aka const std::basic_string&}’
Here is my code:
#include "stack.h"
string convert(string expression)
{
stack c;
string post = " ";
for (int i =0; i<expression.length(); i++)
{
c.push(expression[i]);
}
}
int main()
{
string expression;
cout<<" Enter a Post Fix expression: ";
getline(cin,expression);
return 0;
}
and here is the push function written in another .cpp file
void stack::push(const stack_element & item)
{
cout<<"Inside push \n";
stack_node *p = new stack_node;
p->data = item;
p->next = s_top;
s_top = p;
}
do not use const as parameter in your push function