Figure 7.3 passes integer max_items to the queue abstraction as a generic parameter. Write an alternative version

Question:

Figure 7.3 passes integer max_items to the queue abstraction as a generic parameter. Write an alternative version of the code that makes max_items a parameter to the queue constructor instead. What is the advantage of the generic parameter version?

Figure 7.3:

template class queue { item items [max_items]; int next_free, next_full, num_items; public: queue () : next_free(0), next_full(0), num_items (0) { } bool enqueue (const item& it) { if (num_items == max_items) return false; ++num_items; items [next_free] it; next_free (next_free + 1) % max_items; %3D return true; bool dequeue (item* it)

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: