62 534
Assignments Done
98,8%
Successfully Done
In June 2018

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.
Expert's answer
#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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions