0

I don't quite understand the entirety of the situation that could have led to this, I made quite a large amount of changes to this function, but it seems that this isn't a function issue rather than an issue in the function calling this function.

main(){
    //set up variables...
    //theVector is made on the spot using a constructor
    Player thePlayer(proper, variables, here);
    Map theMap();
    theMap.functionThatAddsValues(stuff);
    std::map<ObjectName, Drawing> theMap;
    //This map is filled by using theMap[ObjectName::TheObject] since
    //this is mapped by its first values being enumerated data.
    movement(theVector, thePlayer, theMap, theDrawings);
    //other stuff
}

void movement(sf::Vector2f theVector, Player thePlayer, Map theMap, std::map<ObjectName, Drawing> theDrawings){
    //use the joyous variables
}

If this information is too vague, I can do a code dump link later of the file, I just think the code is too big to post here in its entirety since it has both functions and lines of codes that I plan on removing due to deprecation, and functions that aren't finished yet (as shown by the errors).

Edit: Forgot to mention the error:

/home/sir-lulzalot/Testland/sfml/SFMLink/main.cpp:277: error:
 undefined reference to `movement(sf::Vector2<float>, Player, Map, std::map<ObjectName,
 Drawing, std::less<ObjectName>, std::allocator<std::pair<ObjectName const, Drawing> > >)'

Edit2: Here's a dump of the main.cpp http://pastebin.com/TyCzWyfK

Edit3: Derp found answer.

A016090
  • 499
  • 1
  • 4
  • 11

2 Answers2

3

For a start, this line probably doesn't do what you think it does:

Map theMap();

This declares a parameter-less function named theMap which returns a Map. (see here for the reason why). I'm guessing you probably intended to create a variable named theMap of type Map, in which case you need to remove the parentheses.

You then use the same name (theMap) for a variable of type std::map<ObjectName, Drawing>. I'm going to hazard another guess and say that you meant for this variable to be called theDrawing.

Beyond that, you haven't shown the code for variables theVector or theDrawings, so if you want more answers, I suggest you put together a SSCCE. Or in other words, do not leave out any code which is necessary for generating the error.

Community
  • 1
  • 1
JBentley
  • 6,099
  • 5
  • 37
  • 72
  • http://pastebin.com/TyCzWyfK Here's a copy of the main file, I don't believe the other .hs/.cpps are required. But I can put them up at request. – A016090 Dec 27 '13 at 05:34
1

That's a linker error.

You don't have consistent declarations and definitions.

This is the declaration of the movement function at the top of the file:

void movement(sf::Vector2f, Player, Map, std::map<ObjectName, Drawing>);

This is the definition of the movement function:

void movement(sf::Vector2f theVector, Player &thePlayer, Map &theMap, std::map<ObjectName, Drawing> theDrawings){

Notice that the definition takes a Player&, while the declaration says Player.

antiduh
  • 11,853
  • 4
  • 43
  • 66
  • No, he does not define two variables called `theMap`. See my answer. – JBentley Dec 27 '13 at 05:17
  • Fair enough, but I don't think thats the root of the problem, his code seems to be heavily copy-edited for the post, which seems to have introduced a lot of extra errors. – antiduh Dec 27 '13 at 05:18
  • @JBentley Apologies. There's a prototype for void movement, so that's not the issue. I'll do a code dump for y'all in a sec. – A016090 Dec 27 '13 at 05:28
  • @antiduh I've added a dump in case you want to take a look at the full main.cpp http://pastebin.com/TyCzWyfK – A016090 Dec 27 '13 at 05:37
  • NEVER MIND THIS IS IT. I am not the smartest – A016090 Dec 27 '13 at 06:05
  • I've said this a few times this week - as the french say, mise en place. This is a mistake you made because your workspace is a mess - the size of that file is huge. Break it up into smaller parts, individual files or classes etc. – antiduh Dec 27 '13 at 06:08