September 2011
Beginner
650 pages
15h 47m
English
Try This 6-1 Improving the Queue Class
![]()
You can use the private modifier to make a rather important improvement to the Queue class developed in Chapter 5, Try This 5-2. In that version, all members of the Queue class use the default access, which is essentially public. This means that it would be possible for a program that uses a Queue to directly access the underlying array, possibly accessing its elements out of turn. Since the entire point of a queue is to provide a first-in, first-out list, allowing out-of-order access is not desirable. It would also be possible for a malicious programmer to alter the values stored in the putloc and getloc ...
Read now
Unlock full access