c++ - Arrays vs. Doubly Linked Lists for Queue simulation -


i working on assignment school simulating line students , multiple windows open @ registrar's office.

i got queue students down suggested use array windows implementing our queue class made on our own.
don't understand why array work when there other variables want know each window besides student time decrementing.

i'm looking direction or more in depth explanation on how that's possible use array store time each student @ window opposed doubly linked list?

the way see you've got variable number of students , fixed number of windows (buildings don't change often). if make representation of in code use dynamically sized container (a list, vector, queue, etc.) contain students , fixed-size array registers. embody intent of real situation in code, making less else using code makes mistakes related size of registrar's office. choosing container type intended use!

thus can design class hold registers using fixed-size array (or nicer: template-dictated size seeing using c++). can write other registrar-related functions using given size argument , never go out-of-bounds in registrar-array.

lastly: array holds whatever information want hold. can have hold numbers (like int) can have hold objects of type! mean is: create registrar class holds information want collect every individual registrar. create array holds registrar objects. whenever access individual element in array can access information of individual registrar through single reference.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -