I am writing a snakes and ladders game and I defined a function called draw_snake as follows:
void draw_snake(const Cairo::RefPtr<Cairo::Context>& cr,
std::pair<int,int> snake,
std::vector< std::pair<int,int> > boardcoords);
When I make the call to this function I do it as follows:
pair<int, int> snake = make_pair(100,1);
draw_snake(cr, snake, boardcoords);
boardcoords
is a vector of pair<int,int>
. The error message is saying that I have a fourth parameter when i call the function. The error message is this:
myarea.cc:(.text+0x7db): undefined reference to `MyArea::draw_snake(Cairo::RefPtr<Cairo::Context> const&, std::pair<int, int>, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >)'
Where is it getting this allocator from?
You're misreading the error. The function has three parameters.
undefined reference to `MyArea::draw_snake(
Cairo::RefPtr<Cairo::Context> const&,
std::pair<int, int>,
std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >
// ^ The vector's parameters are contained in these brackets ^
)
std::vector
has a default "allocator" parameter. It exists even when you don't specify it.
So the error you're getting is that the exact function you declared is not defined.