Here is your problem - you're reading in
characters with the line:
getline(cin,formula);
so in your string variable "formula", you are saving the
character representation of '1', '2', etc, not the actual values 1 and 2. In other words, if you type "1" into your computer, your computer doesn't actually save it as the integer value 1 - but as something else entirely!
Take a look at the ASCII table :
http://www.asciitable.com/
This table explains how the computer internally stores all the characters we see on screen - the alphabet, numbers, punctuation marks, etc. The decimal representation ("dec") is on the far left of each column, and the character ("chr") is on the far right.
So if you take a look at the table, you'll notice the character "1" has a decimal value of 49, and the character "2" has a decimal value of 50. Therefore, it makes sense that when you pass the
characters 1 and 2 into your "add" function, you are getting 99 (49+50).
What you need to do is convert the
character values into
integer values. Fortunately, this is a common thing in programming so C/C++ has a function that can do this for you - it's called "atoi." Google it to see how it works, what you need to include, etc.
I haven't tested this myself, but you need to change the line
object.add(formula[a]);
to something like (again, haven't tested it for syntax):
object.add( (atoi(formula[a]) );
I hope this helps!