I'm getting:
Error 1 error C2514: 'EmployeeListNode' : class has no constructors
in ListOfEmployee.cpp
But in EmployeeListNode.h I have:
class EmployeeListNode
{
friend class ListOfEmployee;
public:
EmployeeListNode(string name, double salary); //A constructor no?
};
I don't understand why it won't recognise that as a constructor. Sorry if this is a stupid question, but I couldn't find an answer through searching.
Edit: The section of the ListOfEmployee that's giving the errors:
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);
}
} Edit 2: And the ListOfEmployee.h in case it makes a difference:
#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;
};
EmployeeListNode
somewhere. Maybe you have one as a class member and don't initialize it in the initialization list? Please post where the error comes from.