Main program line 29: If the condition is false, only line 30 is skipped. The way you've indented the code suggests that you want to skip the rest of the program. Add braces if necessary.
Overall, you've done a really good job of managing the memory yourself. Most beginners mess this up.
FBFriends::insert
: You forgot to increment used.
FBFriends::is_item
: This returns false when current_index==0. Should it?
FBFriends::find_friend
doesn't return anything if name isn't found. I suggest that you change it to:
1 2 3
|
// Find a friend. If found, then copy the friend to "found" and return true.
// Otherwise leave "found" unchanged and return false.
bool FBFriends::find_friend(const std::string &name, Friend &found) const
|
bool FBFriends::is_friend
: This should call find_friend. E.g.:
1 2
|
Friend dummy;
return find_friend(name, dummy);
|
FBFriends::load: eof() won't return true until you try to read past the end of file. So after reading the last friend, eof() will return true but
ins>>temp
will fail. Change lines 103 & 104 to:
while (ins >> temp) {
Also load() appends items rather than replacing the contents with what's in the file. In other words, if the FBFriends instance contains friends "Bud" and "Lou" before calling load(), it will still contain Bud and Lou after. Is this what you intended?
Please provide the definition for class Friend. It's possible that the crash is there.