Giving precedence to the mathematical operators

Write your question here.
I am having difficulty in giving precedence to the mathematical operators i.e. I want to implement the "DMAS" rule of mathematics. Can anyone help me in this regard?
Operators in C++ do have precedence already.
Level
6 * / % multiplicative Left-to-right
7 + - additive Left-to-right

I doubt you can change that. You might be able to do something with expression templates though.

However, if you are not actually talking about code, but about a "calculator" that reads in text, converts it into expression, and then evaluates the expression -- then your question is about parsing a string into a tree.
Topic archived. No new replies allowed.