You generally want to have a stack, with each token popped on it as it's read.

But I recommend writing a calculator in Bison instead of pure c++. It's easier. Here's an example.