Hello, I'm wondering what the proper syntax is for this. I have a deque of pointers to class objects. I want to perform some actions on the front element, then push it to the back of the deque, and then repeat the process on the new front element. My code compiles just fine, but it doesn't seem to be pushing the element to the back; it just keeps repeating with the same element (unless I use pop to get rid of it, then the deque shifts just as it should).
Line's 6 and 14 will shift the deque just fine, but 7 and 15 do not, so I'm pretty sure something is wrong with my syntax. Could anyone offer any suggestions?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
if(d1.front()->getStrength() == 0){
cout << "Player 1's " << d1.front()->getCharacterType() << " is defeated!\n\n";
//add this character to the death stack
deathStack.push(d1.front());
//remove this character from the deque
d1.pop_front();
d2.push_back(d2.front());
continuePlay();
}elseif(d2.front()->getStrength() == 0){
cout << "Player 2's " << d2.front()->getCharacterType() << " is defeated!\n\n";
//add this character to the death stack
deathStack.push(d2.front());
//remove this character from the deque
d2.pop_front();
d1.push_back(d1.front());
continuePlay();
}