From CPP Reference:
Deleted implicitly-declared copy assignment operator The implicitly-declared or defaulted copy assignment operator for class T is defined as deleted in any of the following is true:
T has a non-static data member that is const
T has a non-static data member of a reference type.
T has a non-static data member that cannot be copy-assigned (has deleted, inaccessible, or ambiguous copy assignment operator)
T has direct or virtual base class that cannot be copy-assigned (has deleted, inaccessible, or ambiguous move assignment operator)
T has a user-declared move constructor
T has a user-declared move assignment operator
So that tells me what causes the deletion but not the why? Can anyone explain for:
T has a non-static data member of a reference type.
and whether this will suffice in my class to deal with the deleted operator:
T& T:operator=(T& t){};
if I have a member of a base class which is a reference type.
Do I need to do anything in my operator=
such as explicitly declare return *this
or will the compiler (g++) handle this for me? Do I have to do anything special with the reference member? Sorry for noob question but I am new to C++ having started off with managed languages (C# and Java).