I am a bit confused about passing by reference. I understand that when you pass by reference into a function, you are able to modify that object you are passing in. Then in the prototype of the function you would have something like, int CDummy::isitme (CDummy& param)
#include <iostream>
usingnamespace std;
class CDummy {
public:
int isitme (CDummy& param);
};
int CDummy::isitme (CDummy& param)
{
if (¶m == this) returntrue;
elsereturnfalse;
}
int main () {
CDummy a;
CDummy* b = &a;
if ( b->isitme(a) )
cout << "yes, &a is b";
return 0;
}
In the main function, object a is passed by reference into the isitme function. But since it says int CDummy::isitme (CDummy& param), shouldn't param already have the address? Why do you need to reference it again by doing ¶m? Is CDummy& param in the parameter of isitme function just indicating that its parameter is passed in as reference? just like when you declare a pointer * just indicates that its a pointer and it's not actually dereferencing it?