C++ ADT Class Array - Clearing an Element?

James Shields

New member
I'm having a hard time getting this to work the way I want it to. I am using Abstract Data Type (Class). Here are is the first part of code:

class Person
{
public :
char name[SIZE2];
int age;
string address;
char gender;
};
Person human[100];

(I.E. To output person#1's age I would do: cout<<human[0].age;)

The purpose of this is to store and manage a database of 100 people. My Menu consists of :
Add Person
Delete Person
Print All Data

The one I need help with is how to DELETE a person. I don't want to delete the element, I want to clear what's in the element.

For instance, the user wants to delete person # 50. I want to clear (or reset?) all values in that structure and then I would swap the cleared structure to the end or just re-sort the array.

I don't know if I would have to clear out each member of the structure or if I could clear out an entire structure.
I imagine there is a command similar to: clear(human[55].age) if I need to clear each member.

or

clear(human[55]) if I can clear the structure.

Is there a way to do this? I can't find a command anywhere in my book or from searching.
If there isn't a command, should I be going about this a different way then?
Thanks!
 
Back
Top