60 537
Assignments Done
97,9%
Successfully Done
In April 2018

Answer to Question #31883 in C++ for Crews

Question #31883
Consider the following buggy function:
Employee read_employee()
{
cout << "Please enter the name: ";
string name;
getline(cin, name);
cout << "Please enter the salary: ";
double salary;
cin >> salary;
Employee r(name, salary);
return r;
Expert's answer
# include <iostream>
# include <string>
using namespace std;


class Employee
{
private:
string name;
double salary;
public:
Employee(string name_, double salary_)
{
this->name = name_;
this->salary = salary_;
}
Employee(){}
};
Employee read_employee();
int main()
{
Employee r;
r = read_employee();
}


Employee read_employee()
{
cout << "Please enter the name: ";
string name;
getline(cin, name);
cout << "Please enter the salary: ";
double salary;
cin >> salary;
Employee r(name, salary);
return r;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

James Moss
10.02.14, 03:09

How would I make this program execute twice?

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions