Posted by Jon on November 30, 2001 at 07:20:36:
In Reply to: Storing Cars posted by John on November 30, 2001 at 01:12:24:
: When storing the cars into an array(street), does it have to be an array of pointers?
you could make it an array or Car objects but it is more convient to make them Car pointers. If it is a list of Car objects, you have to pass the entire object to the tow truck and then back (except if it is a wrecker). If you use pointers instead, it prevents from the entire Car object from being passed and consequently more efficient. Also, it makes searching the array much easier. You can easily tell if there is a valid Car at a specific location by checking to see the value of the pointer. Otherwise, you would need to compare the dummy, constructor information to the Car to determine if it is valid.
Moral of story: use Car pointers.
Post a Followup