So I have two classes, one for contactInfo and another for contactBook. I create a few contactInfo objects and add them to listofContacts[] array in contactBook using an addContact() function which takes the object sent to it and put in the next available space in listofContacts[]. now I need to create a deleteContact() function which will delete the object passed to it from the lisofContact[]. I am unable to do that since I don't know how to compare the object passed to deleteContact() with the objects in listofContacts[].
here is the code for add and delete function i got so far.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
void addContact(ContactInfo con)
{
listOfContact[objcount] = con;
listOfContact[objcount].index = objcount;
objcount++;
}
void deleteContact(ContactInfo con)
{
int i,j;
for (i = 0; i <= objcount-1; i++)
{
if (listOfContact[i] == con)
{
//deletes listofContact[i] if matches with con
}
}
}