G
GRoll35
I get 4 of those errors. in the same spot. I'll show my parent class,
child class, and my driver.
All that is suppose to happen is the user enters data and it uses
parent/child class to display it.
here is the 4 errors.
c:\C++\Ch15\Employee.h(29): error C2440: '=' : cannot convert from
'char []' to 'char [6]'
c:\C++\Ch15\Employee.h(27): error C2440: '=' : cannot convert from
'char []' to 'char [21]'
c:\C++\Ch15\Employee.h(28): error C2440: '=' : cannot convert from
'char []' to 'char [13]'
c:\C++\Ch15\Employee.h(30): error C2440: '=' : cannot convert from
'char []' to 'char [10]'
this is the part that it don't like in my parent class.
Employee(char n[21], char s[13], char e[6], char h[10]) //constructor
{
name = n;
ssn = s;
empNumber = e;
hire = h;
}
Here is my parent class.
//specification file for the Employee class.
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
class Employee
{
private:
char name[21];
char ssn[13];
char empNumber[6];
char hire[10];
//char name;
//char ssn;
//char empNumber;
//char hire;
public:
//Employee() //default contrusctor
//{
// name =' ';
// ssn =' ';
// empNumber=' ';
// hire=' ';
//}
Employee(char n[21], char s[13], char e[6], char h[10]) //constructor
{
name = n;
ssn = s;
empNumber = e;
hire = h;
}
~Employee() //destructor
{
}
char getName()
{
return name[21];
}
char getSSN()
{
return ssn[13];
}
char getEmpNumber()
{
return empNumber[6];
}
char getHire()
{
return hire[10];
}
};
#endif
**here is my child class
//specification file for the EmployeePay class
#ifndef EMPLOYEEPAY_H
#define EMPLOYEEPAY_H
#include "Employee.h"
class EmployeePay: public Employee
{
protected:
float anPay;
float moPay;
int depend;
public:
//derived class contructor
EmployeePay(char n, char s, char e, char h, float an, float mo, int
de) : Employee(n, s, e, h)
{
anPay = an;
moPay = mo;
depend = de;
}
~EmployeePay() //destructor
{
}
float getAnPay()
{
return anPay;
}
float getMoPay()
{
return moPay;
}
int getDepend()
{
return depend;
}
};
#endif
**here is my driver
//this program gets the info from the parent/child and displays on
screen
#include <iostream>
#include "EmployeePay.h"
using namespace std;
int main()
{
char userName[21], userSSN[13], userNum[6], userHire[10];
float userAnPay, userMoPay;
int userDepends;
//char name[21];
//char ssn[13];
//char empNumber[6];
//char hire[10];
//get all the info from the user
cout <<"Enter the employee's info:\n";
cout <<"Name: ";
cin.getline(userName, 21);
cout << "Social Security Number: ";
cin.getline(userSSN, 13);
cout << "Employee Number: ";
cin.getline(userNum, 6);
cout <<"Hire Date: ";
cin.getline(userHire, 10);
cout << "Annual Pay: ";
cin >> userAnPay;
cout << "Monthly Pay: ";
cin >> userMoPay;
cout << "Dependents: ";
cin >> userDepends;
//define a EmployeePay object and use the data entered by the user
EmployeePay myEmp(userName[21], userSSN[13], userNum[6], userHire[10],
userAnPay, userMoPay, userDepends);
//display the EmployeePay objects properties
cout << "Here are the Employee's details:\n";
cout << "Name: " << myEmp.getName() << endl;
cout << "SSN: " << myEmp.getSSN() << endl;
cout << "Employee Number: " << myEmp.getEmpNumber() << endl;
cout << "Hire Date: " << myEmp.getHire() << endl;
cout << "Annual Pay: " << myEmp.getAnPay() << endl;
cout << "Montly Pay: " << myEmp.getMoPay() << endl;
cout << "Dependents: " << myEmp.getDepend() << endl;
return 0;
}
thank you very much for any help!
child class, and my driver.
All that is suppose to happen is the user enters data and it uses
parent/child class to display it.
here is the 4 errors.
c:\C++\Ch15\Employee.h(29): error C2440: '=' : cannot convert from
'char []' to 'char [6]'
c:\C++\Ch15\Employee.h(27): error C2440: '=' : cannot convert from
'char []' to 'char [21]'
c:\C++\Ch15\Employee.h(28): error C2440: '=' : cannot convert from
'char []' to 'char [13]'
c:\C++\Ch15\Employee.h(30): error C2440: '=' : cannot convert from
'char []' to 'char [10]'
this is the part that it don't like in my parent class.
Employee(char n[21], char s[13], char e[6], char h[10]) //constructor
{
name = n;
ssn = s;
empNumber = e;
hire = h;
}
Here is my parent class.
//specification file for the Employee class.
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
class Employee
{
private:
char name[21];
char ssn[13];
char empNumber[6];
char hire[10];
//char name;
//char ssn;
//char empNumber;
//char hire;
public:
//Employee() //default contrusctor
//{
// name =' ';
// ssn =' ';
// empNumber=' ';
// hire=' ';
//}
Employee(char n[21], char s[13], char e[6], char h[10]) //constructor
{
name = n;
ssn = s;
empNumber = e;
hire = h;
}
~Employee() //destructor
{
}
char getName()
{
return name[21];
}
char getSSN()
{
return ssn[13];
}
char getEmpNumber()
{
return empNumber[6];
}
char getHire()
{
return hire[10];
}
};
#endif
**here is my child class
//specification file for the EmployeePay class
#ifndef EMPLOYEEPAY_H
#define EMPLOYEEPAY_H
#include "Employee.h"
class EmployeePay: public Employee
{
protected:
float anPay;
float moPay;
int depend;
public:
//derived class contructor
EmployeePay(char n, char s, char e, char h, float an, float mo, int
de) : Employee(n, s, e, h)
{
anPay = an;
moPay = mo;
depend = de;
}
~EmployeePay() //destructor
{
}
float getAnPay()
{
return anPay;
}
float getMoPay()
{
return moPay;
}
int getDepend()
{
return depend;
}
};
#endif
**here is my driver
//this program gets the info from the parent/child and displays on
screen
#include <iostream>
#include "EmployeePay.h"
using namespace std;
int main()
{
char userName[21], userSSN[13], userNum[6], userHire[10];
float userAnPay, userMoPay;
int userDepends;
//char name[21];
//char ssn[13];
//char empNumber[6];
//char hire[10];
//get all the info from the user
cout <<"Enter the employee's info:\n";
cout <<"Name: ";
cin.getline(userName, 21);
cout << "Social Security Number: ";
cin.getline(userSSN, 13);
cout << "Employee Number: ";
cin.getline(userNum, 6);
cout <<"Hire Date: ";
cin.getline(userHire, 10);
cout << "Annual Pay: ";
cin >> userAnPay;
cout << "Monthly Pay: ";
cin >> userMoPay;
cout << "Dependents: ";
cin >> userDepends;
//define a EmployeePay object and use the data entered by the user
EmployeePay myEmp(userName[21], userSSN[13], userNum[6], userHire[10],
userAnPay, userMoPay, userDepends);
//display the EmployeePay objects properties
cout << "Here are the Employee's details:\n";
cout << "Name: " << myEmp.getName() << endl;
cout << "SSN: " << myEmp.getSSN() << endl;
cout << "Employee Number: " << myEmp.getEmpNumber() << endl;
cout << "Hire Date: " << myEmp.getHire() << endl;
cout << "Annual Pay: " << myEmp.getAnPay() << endl;
cout << "Montly Pay: " << myEmp.getMoPay() << endl;
cout << "Dependents: " << myEmp.getDepend() << endl;
return 0;
}
thank you very much for any help!