I am working with a class that is mostly working fine, but I am doing some functionality that I might be having a recursive function return a NULLpointer of the class type as a control, and so it might be assigning a NULL pointer to my class object so long story short:
Thing& Thing::operator=(Thing * _other){
if (_other == NULL){
*this = NULL; // compiler throws here
return *this;
}
// does other assignment work
return *this;
}
my compiler VS2010 throws that this is not an I-value. so how do I set the value to NULL, or is it even possible to set an item to NULL from inside?
EDIT: modified this to *this though for some reason now the program breaks with infinite calls to the assignment operator. no idea what is going on
what are the member variables of Thing class?
if you want to show that the object is somehow without value or not intialized, you would better assign fileds 0 (for integers) and null(for pointers) etc, instead of assigning “this” which is constant.