Can anyone help me to understand -> overloading to access data members in a class(c++) [closed]

You can’t make that code work as written since x and y are private.

If you make them public, this will work:

XY* operator ->() 
{
    return this;
}

Leave a Comment