no instance of constructor “AcademicStaff::AcademicStaff” matches the argument list

ぐ巨炮叔叔 提交于 2019-12-16 18:06:21

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!