Just use MsgIt->push(Message)
instead of the awkward dereference. The .
operator has a higher precedence than the *
operator, so what's happening is that it's trying to call .
on the iterator rather than what the iterator points to, then trying to dereference the returned value, neither of which are what you want. You'd have to do (*MsgIt).push
to get the desired result using dereferencing.
Also your use of iterators isn't really how you should do it. It should look like:
for(MessageList::iterator MsgIt = MessageList.begin(), MsgIt < MessageList.end(), MsgIt++)
Finally, as @ChronoTrigger mentioned, you haven't actually placed any queue
s in the MessageList
list, at least in this code. So there is nothing to push
to in the first place.