error C2664: 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::getline(_Elem *,std::streamsize)' : cannot convert parameter 1 from 'std::string [100]' to 'char *'
I know it's not supposed to be a char because that would only get one letter instead of a whole name. Please help. And THank You in advance.
//This program demostrates a class and a derived class with constructors.
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
class Employee
{
private:
string EmpName;
int EmpNum;
int HireDate;
public:
void setEmpName(string);
void setEmpNum(int);
void setHireDate(int);
string getEmpName() const;
int getEmpNum() const;
int getHireDate() const;
Employee();
};
void Employee::setEmpName(string x)
{
EmpName = x;
}
void Employee::setEmpNum(int y)
{
EmpNum = y;
}
void Employee::setHireDate(int z)
{
HireDate = z;
}
string Employee::getEmpName() const
{
return EmpName;
}
int Employee::getEmpNum() const
{
return EmpNum;
}
int Employee::getHireDate() const
{
return HireDate;
}
Employee::Employee()
{
cout << "I will ask you some questions about an employee.\n\n";
}
class ProductionWorker : public Employee
{
private:
int Shift;
double HourlyPayRate;
public:
void setShift(int);
void setHourlyPayRate(double);
int getShift() const;
double getHourlyPayRate() const;
ProductionWorker();
};
void ProductionWorker::setShift(int a)
{
Shift = a;
}
void ProductionWorker::setHourlyPayRate(double B)/>
{
HourlyPayRate = b;
}
int ProductionWorker::getShift() const
{
return Shift;
}
double ProductionWorker::getHourlyPayRate() const
{
return HourlyPayRate;
}
ProductionWorker::ProductionWorker()
{
cout << "Input the information requested and\n";
cout << "I will display the employee's information.\n";
cout << "******************************************\n\n\n";
}
int main()
{
ProductionWorker info;
string name[100];
int num;
int date;
int shift;
double rate;
cout << "\nWhat is the employee's name? ";
cin.getline(name, 100);
cout << "\nWhat is the employee's number? ";
cin >> num;
cout << "\nWhat is the employee's hire date?\n";
cout << "(Month day year\n";
cout << "in this format MMDDYYYY\nfor example 01091987. ";
cin >> date;
cout << "\nDoes the employee work shift 1 or shift 2? ";
cin >> shift;
cout << "\nHow much does the employee make per hour? ";
cin >> rate;
info.setEmpName(name[100]);
info.setEmpNum(num);
info.setHireDate(date);
info.setShift(shift);
info.setHourlyPayRate(rate);
cout << "\n\nHere is the employee's data:\n\n";
cout << "Employee's Name:" << info.getEmpName() << endl;
cout << "\nEmployee's Number: " << info.getEmpNum() << endl;
cout << "\nEmployee's Hire Date: " << info.getHireDate() << endl;
cout << "\nEmployee's Shift: " << info.getShift() << endl;
cout << setprecision(2) << fixed;
cout << "\nHourly Pay Rate: $" << info.getHourlyPayRate() << endl << endl;
return 0;
}

New Topic/Question
Reply



MultiQuote




|