this

B

Bill Cunningham

Can anyone explain to me what the <this> pointer does and what it's used
for? I trying to learn in for COM.

Bill
 
J

Josephine Schafer

Bill Cunningham said:
Can anyone explain to me what the <this> pointer does and what it's used
for? I trying to learn in for COM.
It is -
1. A pointer accessible only to nonstatic member functions.
2. A pointer which points to the object for which the member function is
called.
3. Passed by the compiler as a hidden argument to a nonstatic member
function.
E.g. obj.foo (5) can be interpreted as foo (&obj, 5)
4. The expression *this is commonly used to return the current object from a
member function.
return *this;
5. Used to guard against self reference in assignment operator member
function.
if (&Object != this) {
// do not execute in cases of self-reference
6. Non modifiable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,813
Members
47,357
Latest member
sitele8746

Latest Threads

Top