I have an simple beginner questions. Here is the code block:
SimpleString& operator=(const SimpleString& other) {
if(this == &other)
return *this;
const auto new_buffer = new char[other.max_size];
delete[] buffer;
buffer = new_buffer;
length = other.length;
max_size = other.max_size;
std::strncpy(buffer, other.buffer, max_size);
return *this;
}
Here ist the full code: https://pastebin.com/2qYxq10q
I dont understand, why this
is a pointer in the second line and
*this
in the third line should also be pointer, because the return type of the method has to be a pointer.
In my perception in the third line should also stand this
and not *this
.
Has anybody at least a link with the explanation.