我越来越:
Error 1 error C2514: ‘EmployeeListNode’ : class has no constructors
在ListOfEmployee.cpp中
但是在EmployeeListNode.h中我有:
class EmployeeListNode { friend class ListOfEmployee; public: EmployeeListNode(string name,double salary); //A constructor no? };
我不明白为什么它不会认识到它是一个构造函数.
对不起,如果这是一个愚蠢的问题,但我无法通过搜索找到答案.
编辑:给出错误的ListOfEmployee部分:
void ListOfEmployee::insert(string nameIn,double salaryIn){ EmployeeListNode *n1 = new EmployeeListNode(nameIn,salaryIn); EmployeeListNode* tn; if (head){ head = n1; }else{ for (tn = head; tn->next; tn = tn->next); }
}
编辑2:
和ListOfEmployee.h,以防它有所不同:
#pragma once #include<string> using namespace std; class EmployeeListNode; class ListOfEmployee { public: ListOfEmployee(); void insert(string name,double salary); void display(); void deleteMostRecent(); double getSalary(string name); ~ListOfEmployee(); private: EmployeeListNode *head; };