0
Party Party::operator + (const Party& party2)
{
    Party newParty;
    newParty.maxAttendees = maxAttendees + party2.maxAttendees;
    newParty.numAttendees = numAttendees + party2.numAttendees;

    for (int c = 0; c < getNumAttendees(); c++)
        newParty.attendees[c] = attendees[c];

    for (int c = numAttendees, d = 0; c < party2.numAttendees; c++, d++)
        newParty.attendees[c] = party2.attendees[d];

    if (date.compare(party2.date) == 0)
        newParty.date = date;

    if (location.compare(party2.location) == 0)
        newParty.location = location;

    if (organizer.compare(party2.organizer) == 0)
        newParty.organizer = organizer;


}

It is saying Party::operator+ must return a value. I tried returning party2, newParty and such but I get even more errors.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Jeremy S Nero
  • 45
  • 1
  • 7

1 Answers1

1

This error is what it says on the tin; since you declared it to return a Party, you need to return a value at the end of the function:

Party Party::operator + (const Party& party2)
{
    // Some implementation...

    return newParty;
}

It wouldn't make sense not to return a value anyway since addition usually results in a new value of some kind.


Note: You might want to consider making your function const as well since your parameter is const:

Party Party::operator + (const Party& party2) const
{
    //...
}