I have a vector of user defined objects such as
std::vector<UserDefinedClass> list_of_objects;
The UserDefinedClass doesnt have any explicit copy constructor.
Now I would like to make a copy of them. So, I define
std::vector<UserDefinedClass> list_of_objects_copied;
list_of_objects_copied = list_of_objects;
Do I really need a copy constructor to iterate the vector and copy the objects in the vector one by one?
The error is
error: use of deleted function ‘UserDefinedClass& UserDefinedClass::operator=(const UserDefinedClass&)’
If I use a built in object such as int, double etc, I dont have any problem in copying the list.
Class definition
UserDefinedClass {
private:
int &m_a;
public:
UserDefinedClass(int a):m_a(a) {};
};