I have been trying to make a program that uses derived classes but have run into a problem. I get the error type: " error C2440: '=' : cannot convert from 'const char [16]' to 'char' " when I try and intialize a char array of 255 to "Name Unknown" and such. Here is the complete program:
inherit.h
#include<iostream>
using namespace std;
class Person{
public:
Person()
{
name[1]="Name Unknown";
date_of_birth[1]="Date of Birth Unknown";
gender[1]="Gender Unknown";
SSN[1]="SSN Unknown";
address[1]="Adress Unknown";
phone_number[1]="Phone Number Unknown";
}
char name[255];
char date_of_birth[255];
char gender[255];
//bool is_boy;//the gender requirement
//bool is_girl;
char SSN[255];
char address[255];
char phone_number[255];
};
class Dependent: public Person{
public:
Dependent()
{SSN_of_employee[1]="SSN of Employee Dependant on Unknown";}
char SSN_of_employee[255];
};
class Employee: public Person{
public:
Employee()
{
hire_date[0]="Hire Date Unknown";
salary=0.0;
work_location[0]="Work Location Unkown";
work_phone_number[0]="Work Phone Number Unknown";
}
char hire_date[255];
double salary;
char work_location[255];
char work_phone_number[255];
};
class Manager: public Employee{
public:
Manager()
{title[0]="Title Unknown";}
char title[255];
};
class Worker: public Employee{
public:
Worker()
{project[0]="Project Unknown";}
char project[255];
};
main.cpp
#include<iostream>
#include"inherit.h"
using namespace std;
int main()
{
class Person person;
class Employee emplyee;
class Dependent dependent;
class Worker worker;
class Manager manager;
system("pause");
return 0;
}
Any suggestions for how to fix this error list:
error C2440: '=' : cannot convert from 'const char [13]' to 'char'
error C2440: '=' : cannot convert from 'const char [22]' to 'char'
error C2440: '=' : cannot convert from 'const char [15]' to 'char'
error C2440: '=' : cannot convert from 'const char [12]' to 'char'
error C2440: '=' : cannot convert from 'const char [15]' to 'char'
error C2440: '=' : cannot convert from 'const char [21]' to 'char'
error C2440: '=' : cannot convert from 'const char [37]' to 'char'
error C2440: '=' : cannot convert from 'const char [18]' to 'char'
error C2440: '=' : cannot convert from 'const char [21]' to 'char'
error C2440: '=' : cannot convert from 'const char [26]' to 'char'
error C2440: '=' : cannot convert from 'const char [14]' to 'char'
error C2440: '=' : cannot convert from 'const char [16]' to 'char'
Thanks.