Answer to Question #31782 in C++ for Jay

Question #31782
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;
1
Expert's answer
2013-06-11T08:09:03-0400
#include <iostream>
#include <stdlib.h>
#include <string>

using namespace std;

string employee;
string name;
double salary;

string 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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS