01/10/2018, 00:22
Lỗi redefinition of formal parameter 'name2'
#include "WagedEmployee.h"
#include<string>
WagedEmployee::WagedEmployee()
{
//Employee::Employee();
}
WagedEmployee::WagedEmployee(char *name2, double w,double h)
{
::Employee(name2);/
wage=w;
hours=h;
}
void WagedEmployee::nhap()
{
/*cout<<"Nhap ho vs ten: ";
fflush(stdin);
cin.getline(,50);*/
Employee::nhap();
cout<<"Nhap tien luong: ";
cin>>wage;
cout<<"Nhap gio: ";
cin>>hours;
}
void WagedEmployee::xuat()
{
//cout << "Ho Ten: " << aname << endl;
Employee::xuat();
cout<<"Luong Co Ban tinh theo gio: "<<wage<<endl;
cout<<"So gio lam viec: "<<hours<<endl;
cout<<"Luong: "<<wage*hours<<endl;
}
/*istream& operator>>(istream &is,WagedEmployee &x)
{
int
return is;
}
ostream& operator<<(ostream &os,WagedEmployee x)
{
return os;
}*/
nó báo sai ở chổ name2
Error 1 error C2082: redefinition of formal parameter ‘name2’
Bài liên quan
What/where “Employee”???
Lỗi thông báo là bạn đã định nghĩa lại biến “chính thức” là name2. Bạn có thể show code trong WagedEmployee.h được không?
WagedEmployee.h nè bạn
Employee.h
thks
error này tìm hoài ko ra làm sao fix lun
Thử sửa ::Employee(name2) thành ::Employee abcxyz(name2).
Không chuyên C++ nhưng nhớ không nhầm thì cú pháp ::Employee(name2) là tạo một object kiểu Employee với tên name2 (nên nó báo “redefinition formal param”) xong rồi để đó chơi chứ không phải gọi construct :v
sua lai gong zay r no ra 3 error moi
https://drive.google.com/open?id=0BwQGxKQZ69wGVENJSUt3Y0RseGc
đây là full bài của mình.
bây giờ đã hết lỗi rồi nhưng khi chạy đến nhập họ và tên là bị out ra
hàm này sửa lại thành
Tương tự cho các constructor.
thks de minh sua lai xem ntn.