----C++ programming Create .cpp files for the classes in the header files in con
ID: 3799496 • Letter: #
Question
----C++ programming
Create .cpp files for the classes in the header files in contact.h and name.h
Implement Name functions
setFirstName
1 points
setLastName
1 points
printName
1 points
noArg Constructor
1 points
2-arg constructor
1 points
Implement ontact functions
NoArg constructor with numcontacts
1 points
3-arg constructor w/numContacts
1 points
initialize numcontacts
1 points
setNumPhoneNum
1 points
getNumPhoneNum
1 points
setPhoneNumArray
1 points
showNumberofContacts
1 points
displayContact
1 points
setPhoneNumArray - dynamically allocate
1 points
destructor
decrement numcontacts
1 points
resets phone array to nullptr
1 points
deletes phone array
1 points
Compile / Run
compiles with no errors
1 points
runs with no errors
1 points
no additional methods
1 points
name.h
#ifndef NAME_H
#define NAME_H
#include
using namespace std;
class Name {
private:
string firstName;
string lastName;
public:
Name();
Name(string, string);
void setFirstName(string s);
void setLastName(string s);
void printName();
string getFirstName() { return firstName; }
string getLastName() { return lastName; }
};
#endif
----------------------------------------
contact.h
#ifndef CONTACT_H
#define CONTACT_H
#include "Name.h"
#include
using namespace std;
class Contact{
private:
Name name;
string * phoneNumbers = nullptr; // dynamically allocated array of phone numbers
int numberOfPhoneNumbers; // how many phone numbers for this contact
static int numberOfContacts; // how many contacts altogether
public:
Contact();
Contact(string, string, int); // first, last, number of phone numbers
~Contact();
void setNumberOfPhoneNumbers(int);
int getNumberOfPhoneNumbers();
string * setPhoneNumberArray(); // returns a string pointer to the phone array for this contact
int showNumberOfContacts();
void displayContact();
};
#endif
Implement Name functions
setFirstName
1 points
setLastName
1 points
printName
1 points
noArg Constructor
1 points
2-arg constructor
1 points
Implement ontact functions
NoArg constructor with numcontacts
1 points
3-arg constructor w/numContacts
1 points
initialize numcontacts
1 points
setNumPhoneNum
1 points
getNumPhoneNum
1 points
setPhoneNumArray
1 points
showNumberofContacts
1 points
displayContact
1 points
setPhoneNumArray - dynamically allocate
1 points
destructor
decrement numcontacts
1 points
resets phone array to nullptr
1 points
deletes phone array
1 points
Compile / Run
compiles with no errors
1 points
runs with no errors
1 points
no additional methods
1 points
Explanation / Answer
Name.cpp
Name :: Name() {
}
Name ::Name (string fName , string lName)
}
}
}
}
contact.cpp
Contact:: Contact() {
}
Contact :: Contact(string first , string last, int nPhoneNumbers ) // as contact.h has Name (hence firstName and lastName)
}
}
string Contact :: *setPhoneNumberArray(){
}
int Contact :: int showNumberOfContacts() {
return numberOfContacts++ ;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.