问题
I declared
AcademicStaff(int, char *, char *, int , char *, char *,int, char *,char *)
constructor for initiliazing.
When I called the functiion in main I got an error
" 2 IntelliSense: no instance of constructor "AcademicStaff::AcademicStaff" matches the argument list
argument types are: (int, char, char, int, char, char, int, char, char)".
Calling Function :
AcademicStaff headOdDepartment(staffID, *firstName, *lastName, telNo, *address, *email, annualSalary, *title, *status);
myDepartment.setheadOfDepartment(headOdDepartment);
回答1:
You need to call the function with AcademicStaff headOdDepartment(staffID, firstName, lastName, telNo, address, email, annualSalary, title, status);
You're sending the first element if you send *charArray
.
回答2:
Your constructor accepts pointers to strings. See below
AcademicStaff(int, char *, char *, int , char *, char *,int, char *,char *)
but when you are calling constructor you are dereferencing the pointers using * e.g *firstName. See
AcademicStaff headOdDepartment(staffID, *firstName, *lastName, telNo, *address, *email, annualSalary, *title, *status);
Remove the dereferencing and use the following code
AcademicStaff headOdDepartment(staffID, firstName, lastName, telNo, address, email, annualSalary, title, status);
来源:https://stackoverflow.com/questions/30000121/no-instance-of-constructor-academicstaffacademicstaff-matches-the-argument-l