I've recently been trying to make a better version of my previous remake of the classic snake game by implementing data encapsulation and abstraction. I also decided to replace my horrible choice of a linked list for holding the snake's tail co-ordinates with the more sensible choice of a deque. Since I am a beginner and I have honestly no clue what is going on (I'd be worried if I did know what I was doing), I would appreciate some assistance with helping me understand what is wrong with my usage of the deque and how I can fix it.
From what I can gather I believe it has something to do with improper usage of constructors, yet I still have not fully grasped the concept of constructors to be able to properly debug it.
SnakePart.h
#ifndef SNAKEPART_H_
#define SNAKEPART_H_
#include <deque>
class SnakePart {
public:
void advance(int x, int y, bool loose_tail = true);
};
extern std::deque<SnakePart> parts;
#endif /* SNAKEPART_H_ */
SnakePart.cpp
#include "SnakePart.h"
void SnakePart::advance(int x, int y, bool loose_tail) {
std::deque<SnakePart> parts;
parts.emplace_front(x, y);
if(loose_tail)
parts.pop_back();
}