Overloading unary operators using pointers
Hi
Please take a look at this non-compilable example:
Code:
#include <iostream.h>
class test{
public:
int a;
friend operator++(test *b);
};
operator++(test *b)
{
b->a=b->a+1;
}
int main()
{
test asd;
asd.a=1;
&asd++;
return 0;
}
This will only compile if I replace the pointer *b with a reference. In my book it says that the reason why that is the case is because "&asd++ is inherently ambigous", but explains it no further.
What does the author mean by that?
Best,
Niles.