I am doing a program to check for balanced brackets and parenthesis, etc. I created a char to store the info, and when I push the char it works, but it won’t allow me to pop. Anyone know what I can do? Our prof gave us the header file so I cannot change it from int to char in the pop/push function. But I’m curious what I can do to make this work?
void push(int);
void pop(int &);
char ch,i;
IntStack x(50);
int count = 0;
while (fin>>ch)
{
if (ch == '[' || ch=='{' || ch=='(')
{
x.push(ch); //this works
count++;
}
if (ch==']' || ch=='}' || ch==')')
{
x.pop(ch); //this brings an error, i also tried x.pop(ch&) and didnt work too
count--;
}
}
Pass an integer into pop that represents ch, then set ch according the results passed back from the integer.