I'm having an issue passing unique_ptrs to functions, it seems they go out of scope when I pass to askQuestion.
hears my code.
char askQuestion(string *questions[8], unique_ptr<binaryBase>answered) {
bool asked = false;
char input = '0';
while (!asked) { // loop until you find a question that has not been asked
int randomQuestion = (rand() % 8); // generate a random number
if (!(answered->getBit(randomQuestion))) { // check if the question has been answered
getInput(input, *questions[randomQuestion]);
answered->toggleBit(randomQuestion);
asked = true;
}
}
return input;
}
these two functions access unique_ptrs, function below relies on function above for input. when I call askQuestion I get "(variable) cannot be referenced -- it is a deleted function"
bool checkAnswer(char answer, int place, binaryBase* reference) {
/* if the answer is T and the correct answer is true, returns true
if the answer is F and the correct answer is false, returns true
return false otherwise
*/ return((answer=='T'&&reference->getBit(place))||(answer=='F'&&!reference->getBit(place)));
}
binaryBase is a simple custom class and only has a 8 int as data and getters and setters for bits, this treats the 8 bit int as a byte to store "boolean" answers for the program.