c++ - How do I call "operator->()" directly? -
For some strange reason, I need to call operator-> () method directly. For example:
class A {public: void foo () {printf ("Foo"); }}; Class ARF {Public: A * operator-> () {Return; Protected: A * A; }; If I have an arm object, I can call Fu () by writing:
aref-> foo (); However, I want to get an indicator for protected member 'A' How can I do this?
aref.operator-> (); // Returns A * Note that this syntax also works for all other operators:
// One overloaded operators A * aref1 = / / ... A * aref2 = // ... aref1.operator * (); Aref1.operator == (aref2); // ... For cleaner syntax, you can apply a received () function or * to the operator Can overload the and & amp; * Aref as recommended for .
Comments
Post a Comment