This is a pointer, and *this is a pointer that has been dereferenced.
If you had a function that returned this, it would be a pointer to the current object, but a function that returned *this would be a "clone" of the current object, created on the stack unless you defined the method's return type to be a reference.
A small application that demonstrates the difference between working with copies and working with references:
#include <iostream>
class Foo
{
public:
Foo()
{
this->value = 0;
}
Foo get_copy()
{
return *this;
}
Foo& get_copy_as_reference()
{
return *this;
}
Foo* get_pointer()
{
return this;
}
void increment()
{
this->value++;
}
void print_value()
{
std::cout << this->value << std::endl;
}
private:
int value;
};
int main()
{
Foo foo;
foo.increment();
foo.print_value();
foo.get_copy().increment();
foo.print_value();
foo.get_copy_as_reference().increment();
foo.print_value();
foo.get_pointer()->increment();
foo.print_value();
return 0;
}
Output:
1
1
2
3
You can see that when we act on a copy of our local object, the changes do not survive (since it is a whole distinct object), however operating on a reference or pointer does.