Calling class member

This is a discussion on Calling class member within the C++ Programming forums, part of the General Programming Boards category; Another quick question guys. Say I have a class eg.
Code:
class person
{
public:
void goToBathRoom();
void poop();
void ...

calling Object::function() should only be done if 'function' is static. when you just call a function from within an objects function definition, it is implied to be 'this->function()' ie.) that instance of the object is making the function call.

>>calling Object::function() should only be done if 'function' is static.
Even then you don't need to, since calling (an object).(static member function)() is the same as calling (class):static member function)().

The only time when you'd really need to call Classname::function() would be when the function is overloaded in a derived class and you want to call the function from the base class.

In this example, both ptr1 and ptr2 will contain valid pointers to the Person object called 'p'. I believe that's how cout works; its operator<< () is defined to return an ostream&, so what it does is:
1. Output whatever came after the <<
2. Return (*this) (this returns a pointer to itself; so de-reference the pointer and it returns itself).

cout << "Hello! My name is " returns cout, so the next step is cout << name, which returns cout, etc. and you get a nice chain reaction type thing going on

And to answer your question:
pointer->something()
is the same as
(*pointer).something()

So in short, -> is a shortcut that we use because we're lazy. Also, you can overload the -> operator, but that's not done very often so you probably don't need to worry about it. Putting it all together, this->doSomething() is basically saying (this current object).doSomething().

>as pointer to 'class person'..?? or will "this" only return a 'person' pointer...
I'm a bit confuzzled. A pointer to 'class person' and a 'person' pointer are the same thing. this is simply a pointer to the type that the class defines. So in your example, this is a pointer-to-person and *this is a person object.

>any reason to use this instead of returning your own pointer to the object..?
Well, you should be thinking twice about returning a pointer to the object to begin with, but why bother creating another pointer just to return it when this is sitting there waiting to be used?

>>any reason to use this instead of returning your own pointer to the object..?
Yes. For example, if you have a member function which adds a pointer of the object to a static class array for internal use:

It would be hard to do something like that without the use of this. Of course, you could store the pointers in your own array and write your own function and blah blah blah, but that's just an example of something you could do using this (make the class more of an automatic thing)

**EDIT**
Also, like I said... without returning this, you wouldn't be able to chain together a bunch of << with cout. And that's another good reason to use this

**EDIT2**
!@#$%!^% I hate these edit boxes!!! Why does it always screw up my code???