So i'm trying to figure a way to call back to a place in a vector (labelled history) but backwards. It's hard to explain for me.
Basically i'm making a calculator to and I'm trying to be able to call back to a place in the history of it. So for example, a command I get is "h3" which goes to my menu to redo the history item 3 places ago.
I know I need to start with my variable "operand" and do an if statement of: If operand is in range between 0 and history.size()-1 call DoCommand in a recursive fashion with the history item desired as an argument
so I am guessing it's like this: if(((operand >= 0) && (operand <= history.size - 1)) == 0){
}
but then I need to recursively call my DoCommand function using the desired history item as an argument.
1 2 3 4 5 6 7 8 9 10
|
case 'h':
case 'H':
// If operand is in range between 0 and history.size()-1
// call DoCommand in a recursive fashion with the
// history item desired as an argument
if(((operand >= 0) && (operand <= history.size()-1))== 0){
DoCommand(//need something here);
}
break;
|
I am at a loss with that. Any help would be appreciated!
just be clear here's an example of what I want to do:
Say I start with number 10:
I add 10 and get 20
subtract 5 and get 15
then add 5 and get 20
BUT then go back in the history that these instructions are held and recall say step 1 to add 10 again but calling that from the history of the vector so I can add 10 again.