
Patrick B. answered 12/04/19
Math and computer tutor/teacher
using namespace std;
#include <iostream>
#include <string.h>
#define PHONE_NAME_SIZE (255)
#define PHONE_NUM_SIZE (45)
class Phone
{
private:
char name[PHONE_NAME_SIZE];
char number[PHONE_NUM_SIZE];
public:
Phone( char * phoneName, char * phoneNum)
{
strcpy(name,phoneName);
strcpy(number,phoneNum);
}
Phone()
{
memset(name,0,PHONE_NAME_SIZE);
memset(number,0,PHONE_NUM_SIZE);
}
char * GetName() { return(name); }
char * GetNumber() { return(number) ; }
void SetName( char * phoneName ) { strcpy(name,phoneName); }
void SetNumber( char * phoneNum) { strcpy(number,phoneNum); }
};
void OutputPhone( Phone& p)
{
cout << "*****************************" << endl;
cout << " name = >" << p.GetName() << endl;
cout << " phone # = >" << p.GetNumber() << endl;
cout << "*****************************************" << endl;
}
int main()
{
Phone myPhone;
Phone yourPhone;
myPhone.SetName("PATRICK");
myPhone.SetNumber("407-765-4321");
yourPhone.SetName("STANLEY");
yourPhone.SetNumber("123-456-7890");
OutputPhone(myPhone);
OutputPhone(yourPhone);
}