Chương trình em nó báo bị lỗi chỗ dòng này
Employee::Employee(string nameIn, int ageIn, string sexIn, string addressIn, string phoneIn, int hourIn, float salaryIn, string positionIn) : Human(nameIn, ageIn, sexIn), Person(addressIn, phoneIn), Worker(hourIn, salaryIn)
“no instance of constructor “Person::Person” matches the argument list”
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
class Human
{
private:
string name; // Ten
int age; // Tuoi
string sex; // Gioi Tinh
public:
void setName(string); // Gan ten
string getName(); // Doc ten
void setAge(int); // Gan tuoi
int getAge(); // Doc tuoi
void setSex(string); // Gan gioi tinh
string getSex(); // Doc gioi tinh
Human(string nameIn = "", int ageIn = 0, string sexIn = ""); // Khoi tao thong tin ve Nguoi
void show(); // Hien thi thong tin Nguoi
};
void Human::setName(string nameIn)
{
name = nameIn;
}
string Human::getName()
{
return name;
}
void Human::setAge(int ageIn)
{
age = ageIn;
}
int Human::getAge()
{
return age;
}
void Human::setSex(string sexIn)
{
sex = sexIn;
}
string Human::getSex()
{
return sex;
}
Human::Human(string nameIn, int ageIn, string sexIn) // Khai bao phuong thuc ben ngoai lop
{
name = nameIn;
age = ageIn;
sex = sexIn;
}
void Human::show() // Hien thi thong tin nguoi
{
cout << "\nTen: " << name << "\nTuoi: " << age << "\nGioi tinh: " << sex << endl;
}
class Person : public virtual Human // Dinh nghia lop Person ke thua tu lop Human
{
private:
string address;
string phone;
public:
void setAddress(string);
string getAddress();
void setPhone(string);
string getPhone();
Person(string nameIn = "", int ageIn = 0, string sexIn = "", string addressIn = "", string phoneIn = ""); // Khoi tao thong tin ve Ca Nhan
void show(); // Hien thi thong tin Ca Nhan
};
void Person::setAddress(string addressIn)
{
address = addressIn;
}
string Person::getAddress()
{
return address;
}
void Person::setPhone(string phoneIn)
{
phone = phoneIn;
}
string Person::getPhone()
{
return phone;
}
// Khoi tao du tham so
Person::Person(string nameIn, int ageIn, string sexIn, string addressIn, string phoneIn) :Human(nameIn, ageIn, sexIn)
{
address = addressIn;
phone = phoneIn;
}
void Person::show() // Hien thi thong tin Ca Nhan
{
cout << "\nTen: " << getName() << "\nTuoi: " << getAge() << "\nGioi tinh: " << getSex() << "\nDia chi: " << address << "\nSo dien thoai: " << phone << endl;
}
class Worker : public virtual Human
{
private:
int hour;
float salary;
public:
void setHour(int hourIn);
int getHour();
void setSalary(float salaryIn);
float getSalary();
Worker(string nameIn = "", int ageIn = 0, string sexIn = "", int hourIn = 0, float salaryIn = 0);
void show();
};
void Worker::setHour(int hourIn)
{
hour = hourIn;
}
int Worker::getHour()
{
return hour;
}
void Worker::setSalary(float salaryIn)
{
salary = salaryIn;
}
float Worker::getSalary()
{
return salary;
}
Worker::Worker(string nameIn, int ageIn, string sexIn, int hourIn, float salaryIn) : Human(nameIn, ageIn, sexIn)
{
hour = hourIn;
salary = salaryIn;
}
void Worker::show()
{
cout << "\nTen: " << getName() << "\nTuoi: " << getAge() << "\nGioi tinh: " << getSex() << "\nGio lam viec: " << hour << "\nLuong: " << salary << endl;
}
class Employee : public Person, public Worker
{
private:
string position;
public:
void setPosition(string positionIn);
string getPosition();
Employee(string nameIn = "", int ageIn = 0, string sexIn = "", string addressIn = "", string phoneIn = "", int hourIn = 0, float salaryIn = 0, string positionIn = "");
void show();
};
void Employee::setPosition(string positionIn)
{
position = positionIn;
}
string Employee::getPosition()
{
return position;
}
Employee::Employee(string nameIn, int ageIn, string sexIn, string addressIn, string phoneIn, int hourIn, float salaryIn, string positionIn) : Human(nameIn, ageIn, sexIn), Person(addressIn, phoneIn), Worker(hourIn, salaryIn)
{
position = positionIn;
}
void Employee::show()
{
cout << "\nTen: " << getName() << "\nTuoi: " << getAge() << "\nGioi tinh: " << getSex() << "\nDia chi: " << getAddress() << "\nSo dien thoai: " << getPhone() << "\nGio lam viec: " << getHour() << "\nLuong: " << getSalary() << "\nChuc vu:" << position << endl;
}
int main()
{
Employee employee("Nguyen Van A", 30, "Nam", "TPHCM", "0987654321", 250, 50000000, "Giam doc");
cout << "\nThong tin Nhan Vien";
employee.show(); //phuong thuc cua lop Employee
cout << "\nThong tin Ca Nhan";
employee.Person::show(); //phuong thuc cua lop Person
cout << "\nThong tin Nguoi Lao Dong";
employee.Worker::show(); //phuong thuc cua lop Worker
cout << "\nThong tin Nguoi";
employee.Human::show(); //phuong thuc cua lop Human
system("pause");
return 0;
}


83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?