(assume GetOpponentName() returns the value of a member called opponentName)
As you can see the first qDebug print is normal, as it should be, and the second qDebug should print the same, but it prints an empty QString. The insert function is somehow "erasing" the members's data of the matchInfo class. Any reasons why?
It is true that I have not created my own assignment operator, but I do not believe I need one. matchInfo has no pointers (unless the string is), so shallow copying should work.
I do not know if this helps, but I believe it has something to do with the constructor of the matchInfo class. It seems to error when I do not provide the default argument (which is for opponentName and it is "").
That's what I thought as well. That seems awfully inconvenient way to do it then. Why must they construct the matchInfo class BEFORE I even insert anything?
Am I trying to copy arg_matchInfo into the matchInfo part in the pair class? If so, should my copy constructor be for matchInfo being assigned to another matchInfo?
Yes. There are at least two copies, one when arg_matchInfo is copied into the pair and another one when it is copied from the pair into the map. The copy constructor is only required if there is no move constructor.
If so, should my copy constructor be for matchInfo being assigned to another matchInfo?
Not sure what you mean. matchInfo needs a copy constructor or a move constructor, that's all.
I did a little more research and found that it has to do with the insert function inserting the pair.
And what did you find, did you fix the problem? I do this everyday, inserting object into maps, and they copy everything just fine.
I am not sure what "break point" you are speaking of, though.
A break point is something you can enable/disable in a debugger at a given line of code. When running the program in debug mode, when that line is about to be executed the program stops execution at that point. You can then "step" over or in the code line by line. By doing this, after the insert into the map, you can then mouse over your map (or add to a watch list) and inspect the contents of your actual map. I'm surprised you are not familiar with break points, it's a crucial part of debugging imo.
Also, I would suggest using the member initialization list for all constructors/copy constructors where possible. Your resulting Ctor would look like:
It doesn't make sense that it would work like that but not with the insert, so it appears the assignment for the class is working as intended but not the copy constructor, which is why I was interested. Anyhow, good job.