Answer to Question #29933 in C++ for rishi taukoordass

Question #29933
Implement a thread safe class to manage a queue of objects.Accessing the front of the queue should be a blocking operation when the queue is empty.
1
Expert's answer
2013-05-16T10:33:55-0400
#include<iostream>
#include<string>
#include<queue>
using namespace std;

class safe:public queue<double>{
public:
double front(){
if (this->empty()==1) return 0;
else return this->queue::front();
}
};

int main()
{
safe s;
s.push(1);
cout<<s.front()<<endl;
s.pop();
cout<<s.front()<<endl;

system("PAUSE");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS