【发布时间】:2016-05-07 02:33:53
【问题描述】:
这是我的队列声明
// TODO: Declare a queue here - e.g. as a global variable
queue<string>myQueue;
这就是我认为我的问题所在。每当我运行程序时,我都会收到一条错误消息,指出“deque iterator not dereferencable”。
string receiveMessage()
{
string messageValue = noMessage; // Don't change this value unless there is a message - default is improtant
messageQueueMutex.lock();
try
{
// TODO: Set hasMessages to true if your queue is not empty, otherwise set it to false:
if(!myQueue.empty())
{
bool hasMessages = true;
}
else
{
bool hasMessages = false;
}
// TODO: Remove the first message from your queue and place it in messageValue:
messageValue = myQueue.front();
myQueue.pop();
}
catch (...)
{
cout << "Exception occurred - check your code!" << endl;
}
messageQueueMutex.unlock();
return messageValue;
}
【问题讨论】: