I am using Microsoft visual studio express 2012 and am using the C++ language...
ID: 3534062 • Letter: I
Question
I am using Microsoft visual studio express 2012 and am using the C++ language...I put the question in red...
Your boss, Juliet Jones, is getting married and decides to change her
name. Complete the following program so that you can type in the new name for
the boss:
int main()
{
Employee boss("Juliet, Jones", 45000.00);
// Your code goes here; leave the code above and below unchanged
cout << "Name: " << boss.get_name() << " ";
cout << "Salary: " << boss.get_salary() << " ";
return 0;
}
The problem is that there is no set_name member function for the Employee class.
Hint: Make a new object of type Employee with the new name and the same salary.
Then assign the new object to boss.
Explanation / Answer
int main()
{
Employee boss("Juliet, Jones", 45000.00);
// Your code goes here; leave the code above and below unchanged
cout << "Name: " << boss.get_name() << " ";
cout << "Salary: " << boss.get_salary() << " ";
char name[20];
int salary;
cout << "Enter new name : ";
gets(name);
cout << "Enter Salary : ";
cin >> salary;
Employee temp(name,salary);
boss = temp;
cout << "Name: " << boss.get_name() << " ";
cout << "Salary: " << boss.get_salary() << " ";
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.