vascoFG
vascoFG

Reputation: 129

Vector of pointers as a template argument

I'm doing this project to manage a bank and I'm trying to implement code to edit an employee object.

template <class val>
void Bank::updateVector(unsigned int ID, vector<val*> upVector, val* upValue)
{
  deleteByID(ID, upVector);
  upVector.push_back(upValue);
}

This is the call to the function:

employee *new_employee= new employee(name,birthDate,address,postalCode, NIF,  BI,  phone,  salary,  post,  qualifications, id);
updateVector(id,employees,new_employee);

I'm getting an undefined reference error:

undefined reference to `void Bank::updateVector<employee>(unsigned int, std::vector<employee*, std::allocator<employee*> >, employee*)'

Why is this happening?

Thank you for your help

Upvotes: 0

Views: 172

Answers (2)

Orunner
Orunner

Reputation: 424

Perhaps you did it already, but wanna make sure, this should be put in the header where your class is defined.

Upvotes: 1

user1017485
user1017485

Reputation: 699

Im not too sure on this but i think this is happening because you created updateVector as a template yet, you didn't specify the class type

Im pretty sure it would be

updateVector <employee> (id, employees, new_employee);

Sorry if I got this wrong.

Upvotes: 0

Related Questions