Is it neccessary to check both the stopping conditions simultaneously, when we are doing it again in another step?
Real world Example
I want to ask that why we are checking for two conditions, i.e, 1. is queue empty and 2. is time greater than 6 pm simultaneously when we have to again check for 1st condition. So, can we not just check them at different time so that we don’t have to check for them again individually.
@jaiskid
The queue can get empty at any instance. If that were to happen and we didn’t check that !q.empty() and went on to access q.front() element , that would give a runtime error.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.