189. this Pointer

Question.6

A copy assignment operator uses this to detect self-assignment:

Buffer& operator=(const Buffer& other) {
   if (this == &other) return *this; // Self-check
   delete[] data;
   data = new uint8_t[other.size];
   memcpy(data, other.data, other.size);
   return *this;
}

What does this == &other check?

Need Help? Refer to the Quick Guide below

Select Answer