Thats what your looking for in the body. Your looking to return the vector you created and reference the array through the int you created when you called it in the operator overload. Good luck!
1.) Use friend function to overload the stream insertion '<<' operator, so that you can directly print out the contents of the next person in the address book. You should set this up so that after the last person in the address book is printed, then printing will start over from the beginning.
1 2 3 4 5 6 7 8 9 10 11 12 13
ostream &operator<<(ostream &output, addressBook &ab) // Creates a output stream,
//calls the operator <<, with the left side being labeled output, and the right side
//associated to the addressbook, and an instance of that book your creating called "ab"
{
PERSON temp; // an instance of the struct
ab.getPerson(tmp); // use the addressbook you've created to associate this with
//the addPerson function, and tie it into the struct (temp) you just created
output << tmp.fName << "\t" << tmp.lName
<< "\t" << tmp.Address << endl; // output the information
return output;
}
Overload the '+=' so that a new PERSON can be added to the end of the address book.
1 2 3 4 5
addressBook &addressBook::operator +=(PERSON &p) // regular overloaded operator
{
this->addPerson(p);
return *this; // this is important, you need to acssociate with the addressbook with this
}
Overload the '[]' operator so that a person can directly get at the element of the address book they are searching for.
1 2 3 4 5
PERSON &addressBook::operator [](int n) // calling your struct, getting the operator
//through addressbook, and creating an int for your array [].
{
return people[n]; // simply return the vector, and tie it in with your int for the array.
}
Hope that all makes sense. Now I'm off to work on the next assignment, converting all my CStrings to strings..fun right?