Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does assignment to *this do (*this = val)?

Tags:

c++

this

qt

I was browsing Qt sources, and noticed this

QUuid &operator=(const GUID &guid)
{
    *this = QUuid(guid);
    return *this;
}

I've never seen assignment to "this" before. What does assignment to "this" do?

like image 459
ckain Avatar asked Jan 19 '11 10:01

ckain


1 Answers

That is not an assignment to this but to the object pointed by this. That will effectively call operator=( QUuid const & ) on the current object.

like image 137
David Rodríguez - dribeas Avatar answered Oct 16 '22 14:10

David Rodríguez - dribeas