Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Family::RemoveAChild(long FatherSSN, long childSSN)
- {
- husbandPtr husb = top;
- if(!searchHusband(FatherSSN))
- {
- cout << "\nChild cannot be added becasue father does not exist" << endl;
- return;
- }
- while(husb != NULL)
- {
- if(husb -> SSN == FatherSSN)
- break;
- husb = husb -> nextFamily;
- }
- if(husb -> myWife == NULL)
- {
- cout << "The child was not removed. The mother does not exist." << endl;
- return;
- }
- wifePtr wif = husb ->myWife;
- if(wif -> myChildren == NULL)
- {
- cout << "The child was not removed. This couple has no children" << endl;
- return;
- }
- childPtr curr = wif -> myChildren;
- if(curr ->SSN == childSSN)
- {
- childPtr delChild = wif -> myChildren;
- wif -> myChildren = curr -> mySibling;
- cout << "deleting child: " << delChild -> fname << endl;
- delete delChild;
- return;
- }
- curr = curr -> mySibling;
- while(curr != NULL)
- {
- if(curr ->SSN == childSSN)
- {
- childPtr delChild = curr;
- curr = curr ->mySibling;
- delete delChild;
- return;
- }
- curr = curr -> mySibling;
- }
- cout << "The child does not exist." << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement