Undefined reference to error is showing an extra parameter for my function, GTKMM C++-Collection of common programming errors

I am writing a snakes and ladders game and I defined a function called draw_snake as follows:

void draw_snake(const Cairo::RefPtr& cr, 
                std::pair snake, 
                std::vector< std::pair > boardcoords);

When I make the call to this function I do it as follows:

pair snake = make_pair(100,1);
draw_snake(cr, snake, boardcoords);

boardcoords is a vector of pair. 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 const&, std::pair, std::vector)'

Where is it getting this allocator from?

  1. You’re misreading the error. The function has three parameters.

    undefined reference to `MyArea::draw_snake(
             Cairo::RefPtr const&,
             std::pair,
             std::vector
    //                  ^ 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.

Originally posted 2013-11-27 12:09:11.