224 Part III
width = MIN;
if (height < MIN)
std::cout << "Height is too small\n";
height = MIN;
}
What the programmer should have written is:
if (width < MIN) {
std::cout << "Width is too small\n";
width = MIN;
}
if (height < MIN) {
std::cout << "Height is too small\n";
height = MIN;
}
Answer 14: The statement:
save_queue = a_queue
copies a queue of size 30 to a queue of size 20. In other words, the assign-
ment operator (as implemented) allows us to copy different size queue.
We should not be allowed to do this.
There are four ways to solve this problem:
1. Use the STL
queue
class.
2. Make the assignment operator private (and not allow any assign-
ments).
3. Change the assignment operator so that it throws an exception if the
size of the queue is not the sa