I have three files listed below that I have to combine together to compile and g
ID: 3647223 • Letter: I
Question
I have three files listed below that I have to combine together to compile and get the result shown in the image. How do I set this up in the compiler to get everything to work together? I can use either DEV C++ or Microsoft Visual 2010
// PhoneDataMain.cpp
#include "PhoneData.h"
//main function
int main()
{
//two PhoneData objects
PhoneData pd1("Susan Meyers", "414 444-4444");
PhoneData pd2("Joy Rodgers", "888 888-8888");
//displaying objects details using getter functions
//PhoneData1
cout<<" Phone Data 1: "<<endl;
cout<<" Name: "<<pd1.getName()<<endl;
cout<<"Phone Number: "<<pd1.getPhoneNumber()<<endl;
//PhoneData2
cout<<" Phone Data 2: "<<endl;
cout<<" Name: "<<pd2.getName()<<endl;
cout<<"Phone Number: "<<pd2.getPhoneNumber()<<endl;
cout<<endl;
system("pause");
return 0;
} //end of the main
// PhoneData.cpp
#include "PhoneData.h"
//no argument constructor
PhoneData ::PhoneData()
{
//initializes both data members to empty strings
name = "";
phoneNumber = "";
}
//two argument constructor
PhoneData ::PhoneData(string name,string number)
{
//initializes both variables with appropriate
//passed arguments
this->name = name;
phoneNumber = number;
}
//setter method for name
void PhoneData :: setName(string name)
{
this->name = name;
}
//setter method for phoneNumber
void PhoneData :: setPhoneNumber(string number)
{
this->phoneNumber = number;
}
//getter method for name
string PhoneData :: getName() const
{
return name;
}
//getter method for PhoneNumber
string PhoneData :: getPhoneNumber() const
{
return phoneNumber;
}
#ifndef PHONE_DATA_H
#define PHONE_DATA_H
#include <iostream>
#include <string>
using namespace std;
/******* Class PhoneData Specification ********/
class PhoneData
{
private:
string name;
string phoneNumber;
public:
// 2 parameter constructor
PhoneData(string, string);
// defualt constructor
PhoneData();
// mutator functions
void setName(string);
void setPhoneNumber(string);
// accessor functions
string getName() const;
string getPhoneNumber() const;
};
#endif
Explanation / Answer
Create a project in Microsoft Visual Studio 2010 and add these header files in that project and then run it as a project and include these header files in main program file. i this than you will b able to get the result...