没有构造函数的实例" AcademicStaff :: AcademicStaff"匹配参数列表

时间:2015-05-02 08:32:19

标签: c++ intellisense

我宣布了

AcademicStaff(int, char *, char *, int , char *, char *,int, char *,char *) 

初始化的构造函数。

当我在main中调用函数时出现错误

 "  2   IntelliSense: no instance of constructor "AcademicStaff::AcademicStaff" matches the argument list
            argument types are: (int, char, char, int, char, char, int, char, char)".

调用功能:

AcademicStaff headOdDepartment(staffID, *firstName, *lastName, telNo, *address, *email, annualSalary, *title, *status);
myDepartment.setheadOfDepartment(headOdDepartment);

2 个答案:

答案 0 :(得分:0)

您需要使用AcademicStaff headOdDepartment(staffID, firstName, lastName, telNo, address, email, annualSalary, title, status);调用该函数 如果您发送*charArray,则会发送第一个元素。

答案 1 :(得分:0)

您的构造函数接受指向字符串的指针。见下文

AcademicStaff(int, char *, char *, int , char *, char *,int, char *,char *) 

但是当你调用构造函数时,你使用* eg * firstName取消引用指针。见

AcademicStaff headOdDepartment(staffID, *firstName, *lastName, telNo, *address, *email, annualSalary, *title, *status);

删除解除引用并使用以下代码

AcademicStaff headOdDepartment(staffID, firstName, lastName, telNo, address, email, annualSalary, title, status);