Overload dereference operator
Posted
by zilgo
on Stack Overflow
See other posts from Stack Overflow
or by zilgo
Published on 2010-03-24T07:52:29Z
Indexed on
2010/03/24
7:53 UTC
Read the original article
Hit count: 373
c++
|operator-overloading
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?
© Stack Overflow or respective owner