I have two classes: PersonnelLists and Employee. I create an instance of PersonnelLists in my main form, for example:
int main() { PersonnelLists example;
PersonnelLists uses a constructor to initialize a member of the employee list, number of employees, and array size:
PersonnelLists::PersonnelLists(): List(new Employee[SIZE]), numEmployees(0), arraySize(SIZE){ }
This leads to the creation of empty zero employees (I think?):
Employee::Employee(): employeeNumber(0), name(NULL), department(NULL) { }
On this line, I get an invalid null pointer error.
I am new to C ++, new to Java program. I'm still new to pointers, so I'm not quite sure what I'm doing wrong here.
UPDATE: As requested, here is the definition of the Employee class:
#include <iostream> class Employee { public: Employee(); //constructor Employee(std::string name, std::string deparment); void Print() const; //Print this employee details void setEmployeeNo(int employeeNum); private: int employeeNumber; std::string name; std::string department; };
source share