Question: C + + Define a default constructor that initializes the data members, integer areaCode, integer number, and string name, with the default values - 1
C
Define a default constructor that initializes the data members, integer areaCode, integer number, and string name, with the default
values and "Unknown", respectively.
Ex: If the input is Ken, then the output is:
Area code: Number: Name: Unknown
Area code: Number: Name: Ken
Note: The class's print function is called first after the default constructor, then again after the inputs are passed to the setters.
Define a default constructor that initializes the data members, integer areaCode, integer number, and string name, with the default values and "Unknown", respectively.
Ex: If the input is Ken, then the output is:
Area code: Number: Name: Unknown
Area code: Number: Name: Ken
Note: The class's print function is called first after the default constructor, then again after the inputs are passed to the setters.
#include
#include
using namespace std;
class Message
public:
Message;
void SetAreaCodeint messageAreaCode;
void SetNumberint messageNumber;
void SetNamestring messageName;
void Print;
private:
int areaCode;
int number;
string name;
;
Your code goes here
void Message::SetAreaCodeint messageAreaCode
areaCode messageAreaCode;
void Message::SetNumberint messageNumber
number messageNumber;
void Message::SetNamestring messageName
name messageName;
void Message::Print
cout "Area code: areaCode Number: number Name: name endl;
int main
int newAreaCode;
int newNumber;
string newName;
Message myMessage;
myMessage.Print;
cin newAreaCode;
cin newNumber;
cin newName;
myMessage.SetAreaCodenewAreaCode;
myMessage.SetNumbernewNumber;
myMessage.SetNamenewName;
myMessage.Print;
return ;
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
