"&" Operator confusion

As I see in some code having something like "ClassName&".
For example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// this demo
// check if a parameter passed to a member function is the object itself
#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;
}

void main () {
	CDummy a;
	CDummy* b = &a;
	if (b -> isitme(a)) {
		cout << "yes, &a is b";
	}
}


I know "ClassName*" is used to declare a pointer to a class instantiation. But what is "ClassName&"? What is the difference between the "&" reference operator and this "&" in "ClassName&"?

Sorry if it is a stupid question!
Thank for any help.
I know "ClassName*" is used to declare a pointer to a class instantiation.

Similarly, ClassName& is used to declare a reference to a variable.

Example:
1
2
3
4
5
6
7
8
9
10
int x = 6;
int& rx = x;
rx = 16;
//x == 16, rx == 16

/*Same with pointers*/
int x = 6;
int *px = &x;
*px = 16;
//x == 16, *px == 16 
Thank R0mai! I got it.
Topic archived. No new replies allowed.