Hi, There is short explanation of queue at cplusplus.com site which tells that queue should contain front() and back() functions. As I have tested in VC++, if I use queue from <queue> and call any of these functions for an empty queue, program crashes. Could this problem be solved by simply adding a throw, in case when queue is actually empty, so front and back would throw an exception which'd be caught by try block? ( of course I am talking about queue, one would create, as I have done) Here is my simple solution of this problem. struct Exception{ …

Member Avatar
Member Avatar
+0 forum 3

The End.