Question: Why will my code not compile, I am looking for a correction to my code not a whole new code? #include #include using namespace std;
Why will my code not compile, I am
looking for a correction to my code not a whole new code?
#include
#include
using namespace std;
class Contact
public:
Contactconst string &name, const string &phoneNumber, const string &email:
namename phoneNumberphoneNumber emailemail
void PrintContactsContact contacts int size;
void SelectionSortContactsContact contacts int size;
private:
string name;
string email;
string phoneNumber;
;
void Contact::PrintContactsContact contacts int sizedisplays contact with name, phone number, and email
for int j ; j ; j
cout namej phoneNumberj emailj endl;
void Contact::SelectionSortContactsContact contacts int sizesorts contacts in alphabetical order within the array
for int i ; i ; i
string tempName;
string tempNumber;
string tempEmail;
if namei namei
sorts name
tempName contactsiname;
contactsiname contactsiname;
contactsiname tempName;
sorts phone number based of off name being sorted
tempNumber contactsiphoneNumber;
contactsiphoneNumber contactsiphoneNumber;
contactsiphoneNumber tempNumber;
sorts email based of off name being sorted
tempEmail contactsiemail;
contactsiemail contactsiemail;
contactsiemail tempEmail;
int main
Contact contactshard codes the three contacts per assignemnt
new ContactJohn Doe", "john@mail.com"
new ContactJane Smith", "jane@mail.com"
new ContactBob Williams", "bob@mail.com"
;
cout "Contacts:" endl;
contacts.PrintContactscontacts; prints contacts in order of input
contacts.SelectionSortContactscontacts; sorts contacts alphabetically
cout "Contacts after sorting:" endl;
contacts.PrintContactscontacts; reprints contacts in new order
for int i ; i ; ireleases allocated memory
delete contactsi;
return ;
main.cpp: In function int main:
main.cpp::: error: request for member PrintContacts in contacts which is of nonclass type Contact
contacts.PrintContactscontacts; prints contacts in order of input
~~~~~~~~~~~~
main.cpp::: error: request for member SelectionSortContacts in contacts which is of nonclass type Contact
contacts.SelectionSortContactscontacts; sorts contacts alphabetically
~~~~~~~~~~~~~~~~~~~~
main.cpp::: error: request for member PrintContacts in contacts which is of nonclass type Contact
contacts.PrintContactscontacts; reprints contacts in new order
~~~~~~~~~~~~
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
