|
-
Jun 9th, 2001, 07:07 PM
#1
Thread Starter
Hyperactive Member
Who wants more posts??
I've got a question but I'm pretty sure there'll be an easy answer.
Spot the difference....
Code:
Object.SubObject(1);
Object->subObject(1);
If this is even correct code I don't know. But I can't tell the difference between it??
eg.
Code:
*Object.SubObject;
Object.SubObject;
Object->SubObject;
Please help...
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Jun 9th, 2001, 08:01 PM
#2
From MSDN...
this
C++ Specific —>
The this pointer is a pointer accessible only within the member functions of a class, struct, or union type. It points to the object for which the member function is called. Static member functions do not have a this pointer.
When a nonstatic member function is called for an object, the address of the object is passed as a hidden argument to the function. For example, the following function call
myDate.setMonth( 3 );
can be interpreted this way:
setMonth( &myDate, 3 );
The object's address is available from within the member function as the this pointer. It is legal, though unnecessary, to use the this pointer when referring to members of the class.
The expression (*this) is commonly used to return the current object from a member function.
Note Modifying the this pointer is illegal in the latest version of C++.
END C++ Specific
Example
// Example of the this pointer
void Date::setMonth( int mn )
{
month = mn; // These three statements
this->month = mn; // are equivalent
(*this).month = mn;
}
hope that helps
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|