Say we are making an address book by creating a class AddressBook. We put a variety of tools in the class, including the option to add a member. If we use a structure to keep track of each person's information, it would look like this:
class AddressBook {
public:
AddressBook()
{
count = 0;
}
void AddPerson();
//More functions..
struct Entry_Structure
{
char firstName[15];
char lastName[15];
char idNumber[15];
};
Entry_Structure entries[100];
unsigned int count;
};
Then we could write the following for the AddPerson function:
void AddressBook::AddPerson()
{
cout << "Entry number " << (count + 1) << " : " << endl;
cout << "Enter subject's first and last name: ";
cin >> entries[count].firstName >> entries[count].lastName;
cout << "Please enter the subject's ID number: ";
cin >> entries[count].idNumber;
++count;
}
However, instead of using a structure for Entry_Structure
, I used a class.
That is, class Entry_Structure
instead of struct Entry_Structure
.
What would I have to change in the program and the following function to make this work?