Question about keyword "this" in tutorial

Hello,

I'm stuck at a part of the tutorial. Here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
using namespace std;
class CDummy {
public:
int isitme (CDummy& param);
};
int CDummy::isitme (CDummy& param)
{
if (&param == this) return true;
else return false;
}
int main () {
CDummy a;
CDummy* b = &a;
if ( b->isitme(a) )
cout << "yes, &a is b";
return 0;
}


What I do not understand is, what does "CDummy& param" in the functions parameters exactly mean? The part which confuses me is the "&" sign. Can someone comment the important parts in the steps and say what these lines do?

Thank you.
That's passing by reference. It was mentioned in http://www.cplusplus.com/doc/tutorial/functions2/
Ah yes, I forgot about that. The entire code makes now sense. Is it correct to say that instead of writing "b->isitme(a)" I could write "a.isitme(a)" ?
Arrow operator -> is for pointers, dot operator . is for references/objects
So...yes?
b is a pointer. why don't you try to see what happens?
I did, I get the same output. But just to make sure I wanted to ask.
Topic archived. No new replies allowed.