You declare/define a zero-arg consructor. Token_Taking(); //Constructor
But you are attempting to use this constructor as if it has two parameters. Token_Taking player(targetval, turnsval);
If you want to pass those two variables as parameters, then change your constructor. Token_Taking(int target, int turns);
1 2 3 4
Token_Taking::Token_Taking(int target, int turns)
: target(target), turns(turns) {
// (patterns is now an empty vector, already defined in the class.)
}
Hello, I already fixed it in the program and edited the rest. Looks better but now I'm getting an unhandled exception in the play function.
I got this: Unhandled exception at 0x00D0718A
So far in my output file I got an "A"
Is it my recursive function lacking something?
Assuming that you designed this program and then coded this from the design - then you know how it's supposed to work. As it's not then the first thing to do is to use the debugger to debug the program - trace the execution path, watch the variable contents etc. When this deviates from that expected then you're found a problem - which is either with the coding or the design. Fix that. Then repeat this until the program works as expected.
Debugging is a skill which needs to be acquired and honed. Unfortunately this is very often either not taught or not taught well.
Probably. This is where a debugger can help, so you can step through your function and see where it is going awry. In general, recursion is more confusing that iteration, so I tend to avoid recursive functions except for tree-like structures (personally). I would prefer a while loop in this situation.
Lines 25 & 28: You have an if-else chain here. It's either going to enter one branch, or the other, and you have return statements in both branches. Therefore, lines 34 and beyond will never be hit. If there is vital logic within those lines, it will never happen.
I would also add checks before you pop_back to make sure your container has at least 1 element in it.
Alright, I will comment and test each line and see what happens! And no, the code is an homework. I solved the unhandled exception but my logic is still not generating the correct output. I must use recursive (which is very new to me) I will update the code.