How to redeffine operator ->

How i have to redefine the operator -> on my own class?

Thanks in advance
operator-> must take no parameters and return a type for which operator-> is already overloaded. At some point at the end of the chain, it will have to return a pointer. It's a bit of a weird operator.
could i have an example ?
I had think something like this:

1
2
3
4
bool Edificio::operator->(const Edificio& B) {
	 
return *this;
}


It does not take a parameter, nor does it return a bool.

It must take 0 params and typically returns a pointer:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
struct Data
{
    int var;
};

class Example
{
public:
    Data  dat;

    Data* operator -> ()
    {
        return &dat;
    }
};

int main()
{
    Example e;

    // The below lines have the same effect:
    e->var = 5;
    e.dat.var = 5;
}
Yes sure, copy & paste error x..
Anyway Thank you!
Topic archived. No new replies allowed.