#include <iostream>
using namespace std;
class Dummy {
public:
bool isitme (Dummy& param);
};
bool Dummy::isitme (Dummy& param)
{
if (¶m == this) return true;
else return false;
}
int main () {
Dummy a;
Dummy* b = &a;
if ( b->isitme(a) )
cout << "yes, &a is b\n";
return 0;
}
Regarding the code above, in 'isitme' function, the if condition:
if (¶m == this)
Shouldn't be:
if (param == this)
as 'this' is a pointer, and 'param' is a pointer too, so if we said:
if (¶m == this)
that would be a comparison between an address of a pointer (¶m) and a pointer (this), which is not what we are looking for; checking if a parameter passed to a member function is the object itself?