I'm implementing a calculator in C ++ that respects the priorities of parentheses. I am trying to use std :: string :: find_last_of to find the last occurrence of ( and std :: string :: find to find the first occurrence of ). Once that is done, I reckon the content of the extracted substring and continuing with the rest of the string. For example:
1 + 1 * (9 * (11-1 + 2)) I find the last occurrence of (, the first of ) and calculating 11-1 + 2. And so it continues. Is this the right approach to this problem or is there something better? Thank you.
(1+1)*(2+2)?