For a school assignment, I am trying to use a vector of unique pointer's to Employee objects to access the Employee data, but can't figure out the syntax/compiler errors. Can anybody please tell me what I am doing wrong? Have to use a vector of smart pointers in this fashion.
Here is the applicable code:
// Create an Employee
Employee EmpRec;
// Assign value to a uniqueptr
unique_ptr<Employee> TempEmp;
*TempEmp = EmpRec;
// Create a vector of unique_ptr<Employee>
vector<unique_ptr<Employee>> EmpVect;
// Push the TempEmp pointer onto the vector
EmpVect.push_back(TempEmp);
// Iterate through vector, calling display function
//that prints the values of various data inside the Employee object
for (size_t i = 0; i < EmpVect.size(); ++i){
(EmpVect[i])->display(cout);
}
This is how my Display function is defined:
void display(std::ostream& cout) const{
// print data members using cout <<
}
When trying to compile this, I get the following error:
d:\microsoft visual studio 12.0\vc\include\xmemory0(593): error C2280: 'std::unique_ptr>::unique_ptr(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)' : attempting to reference a deleted function