Here's a simplified sample of my code : The .h
class Company {
public:
Company();
void addEmployee(const Employee &emp);
void removeEmployee();
private:
Employees *listEmployees;
};
The .cpp
Company::Company(){ listEmployees = new Employees[16]; }
Company::addEmployee(const Employee &emp) {listEmployee[index]=emp;}
Company::removeEmployee(){ ??? }
I would like to remove an Employee stored in my array. I tried to use :
delete listEmployee[index]; //->"cannot delete expression of type 'Employees'
listEmployee[index]=NULL; //->"no viable overloaded '='"
I didn't find satisfying solution on the web. Also, I'm not very familiar with pointer and reference, maybe the error cames from this. Thanks.
EDIT : I'm NOT allowed to use vectors, I must use arrays.
EDIT2 : Thanks for your answer. Here's the solution I used :
for(int i=indexEmp;i<sizeArray-1;i++){
listEmployees[i]=listEmployees[i+1];
}
Where indexEmp is the index of the employee I want to remove.
std::vector<Employee>.vector? it would be pretty easy then..std::array