I'm writing, essentially, a stack calculator where I can change an expression from normal(infix) notation to prefix and postfix and vice versa, and to be able to evaluate a postfix, prefix, or infix expression and return a value. I have been trying to use a switch statement to determine whether my next character read out of a stack is a number, or an operator, or a parenthesis...so on...

Anyways, I am having a few problems with

1. being able to pop a value off of my stack, into another variable and then to switch off of that variable.

2. testing something like

case '+':
		if(  operatorStack.Peek() = '*')				
                       {
			     //lowerPrecedence = true;
			     strPostfix += operatorStack.Pop();
			}
			else if( operatorStack.Peek= '/')
			{
				strPostfix += operatorStack.Pop();
			}
			else
		        	operatorStack.Push(myStack.Pop());
			break;

**Obviously this is only testing against a plus sign**

However, concerning the if(operatorStack.Peek() = '+'), I am recieving a error stating that : The left-hand side of an assignment must be a variable, property or indexer.

I think that if I could get past this I would be ok.....

Additionally, I copied this same code into a new class library, so that I can call each function when I need it....but I didn't get the compiler error, although I havent yet referenced it into my main so I don't know if it is logically sound....

Any ideas anybody?

Member Avatar for iamthwee

Did this is c++, check it out for ideas.

if( operatorStack.Peek() = '*')
the error comes from assigning using =
you should use == equal operator the above is assignment operator

commented: Good noticing :) +8
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.