Check if object array is empty

Dec 1, 2015 at 10:59pm
I know that an array cannot be "empty," but I need to check if there are still any VALUES in my array of objects

How do I do this?
Dec 1, 2015 at 11:02pm
What are you storing in the array and what do you consider an "empty value"?
Dec 2, 2015 at 12:07am
This tidbit might help you, albeit it shows you an example of arrays of ints, so if you're doing an array of custom class objects, you'll have to do a little more footwork on that.

http://www.cplusplus.com/doc/tutorial/arrays/

Dec 2, 2015 at 2:50am
It is an array of objects, basically I have an array which holds all the patients that are checked in, and I have a function which checks out patients. When I check out a patient, I need to remove the object from the array since it is no longer checked in.

I did this at first:

checkIn[i] = checkIn[i+1]

This shifts the array by 1 index which ultimately overwrites the index I want removed, is this method correct?
Dec 2, 2015 at 9:28am
Sounds like it should work if you also have a variable that keeps track of how many patients you have. When you remove a patient you should not forget to decrement this variable.
Topic archived. No new replies allowed.