Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. void PhoneBook::add(Entry newEntry)
  2. {
  3. if(entries.size() == 0)
  4. {
  5. entries.push_back(newEntry);
  6. }
  7. else
  8. {
  9.  
  10. for(int i = 0; i<entries.size() ; i++)
  11. {
  12.  
  13.  
  14. string str1 = entries[i].getName();
  15. string str2 = newEntry.getName();
  16.  
  17. if(strcmp(str1.c_str(),str2.c_str()) == 0);
  18.  
  19. if(strcmp(str1.c_str(),str2.c_str()) > 0)
  20. {
  21. entries.insert(entries.begin()+i,newEntry);
  22. }
  23.  
  24. if(strcmp(str1.c_str(),str2.c_str()) < 0);
  25.  
  26.  
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement