{"id":1623,"date":"2022-08-30T15:18:04","date_gmt":"2022-08-30T15:18:04","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/27\/undefined-reference-to-error-is-showing-an-extra-parameter-for-my-function-gtkmm-c-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:18:04","modified_gmt":"2022-08-30T15:18:04","slug":"undefined-reference-to-error-is-showing-an-extra-parameter-for-my-function-gtkmm-c-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/undefined-reference-to-error-is-showing-an-extra-parameter-for-my-function-gtkmm-c-collection-of-common-programming-errors\/","title":{"rendered":"Undefined reference to error is showing an extra parameter for my function, GTKMM C++-Collection of common programming errors"},"content":{"rendered":"<p>I am writing a snakes and ladders game and I defined a function called draw_snake as follows:<\/p>\n<pre><code>void draw_snake(const Cairo::RefPtr&amp; cr, \n                std::pair snake, \n                std::vector&lt; std::pair &gt; boardcoords);\n<\/code><\/pre>\n<p>When I make the call to this function I do it as follows:<\/p>\n<pre><code>pair snake = make_pair(100,1);\ndraw_snake(cr, snake, boardcoords);\n<\/code><\/pre>\n<p><code>boardcoords<\/code> is a vector of <code>pair<\/code>. The error message is saying that I have a fourth parameter when i call the function. The error message is this:<\/p>\n<pre><code>myarea.cc:(.text+0x7db): undefined reference to `MyArea::draw_snake(Cairo::RefPtr const&amp;, std::pair, std::vector)'\n<\/code><\/pre>\n<p>Where is it getting this allocator from?<\/p>\n<ol>\n<li>\n<p>You&#8217;re misreading the error. The function has three parameters.<\/p>\n<pre><code>undefined reference to `MyArea::draw_snake(\n         Cairo::RefPtr const&amp;,\n         std::pair,\n         std::vector\n\/\/                  ^ The vector's parameters are contained in these brackets  ^\n         )\n<\/code><\/pre>\n<p><code>std::vector<\/code> has a default &#8220;allocator&#8221; parameter. It exists even when you don&#8217;t specify it.<\/p>\n<p>So the error you&#8217;re getting is that the exact function you declared is not defined.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-27 12:09:11. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I am writing a snakes and ladders game and I defined a function called draw_snake as follows: void draw_snake(const Cairo::RefPtr&amp; cr, std::pair snake, std::vector&lt; std::pair &gt; 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1623","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1623"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1623\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}