Overload dereference operator
- by zilgo
I'm trying to overload the dereference operator, but compiling the following code results in the error 'initializing' : cannot convert from 'X' to 'int':
struct X {
void f() {}
int operator*() const { return 5; }
};
int main()
{
X* x = new X;
int t = *x;
delete x;
return -898;
}
What am I doing wrong?