()+-*/ , how would I be able to compare them if they are all of type char? I looked at the ascii table, but they are all out of order so that isn't a choice.
Keep it simple. You should perhaps say that you want to write a parser.
I guess you already have made the stack class. At any point of time the comparison operator works with characters too.
Keep it simple. You should perhaps say that you want to write a parser.
I guess you already have made the stack class. At any point of time the comparison operator works with characters too.
yes of course !
This is the same thing that I also tried to suggest !
In this case the operator supports , if you find somewhere that doesn't support it. then write your own overloaded operator.
that way make your code more clear and more readable.
yes of course !
This is the same thing that I also tried to suggest !
In this case the operator supports , if you find somewhere that doesn't support it. then write your own overloaded operator.
that way make your code more clear and more readable.
if my stack is like this(with top being at the top of course)
+
*
/
-
and i say (stack->data) > (stack->next->data)
it will read it correctly?
the reason i ask this question is because
+ has a decimal value larger than *.
so, I'm afraid it will use the + operator before *. which is incorrect.
>warning : making that enum will break your code.
Agreed. (+&-) have same weight.
One alternative is ( the non-OOP way) to map a function say weight(char) which gives you the weight of any char you entered.