I have the following function/constructor/method (I’m not sure exactly what it is)
List<T>& List<T>::operator=(const List<T> &x)
where List is a linked list and this is supposed to do assignment. However, I’m not sure exactly what this is supposed to return. Eclipse keeps telling me that control reaches end of non-void function; however, I’m not sure exactly what. I’m new to C++ so keep the answers simple if posssible. Thanks 🙂
Usually, assignment operators return a reference to the object itself, so just end your function with
return *this;. Having an assignment expression have the value of the assignee allows you to write things likea = b = c;andif ((a = get_data()) == c)etc.