C ++ continues to amaze me. Today I learned about the operator → *. It is overloaded, but I do not know how to call it. I manage to overload it in my class, but I don't know what to call it.
struct B { int a; }; struct A { typedef int (A::*a_func)(void); B *p; int a,b,c; A() { a=0; } A(int bb) { b=b; c=b; } int operator + (int a) { return 2; } int operator ->* (a_func a) { return 99; } int operator ->* (int a) { return 94; } int operator * (int a) { return 2; } B* operator -> () { return p; } int ff() { return 4; } }; void main() { A a; A*p = &a; a + 2; }
edit:
Thanks to the answer. To call an overloaded function, I write
void main() { A a; A*p = &a; a + 2; a->a; A::a_func f = &A::ff; (&a->*f)(); (a->*f);
c ++ operator-overloading operator-arrow-star
user34537 Nov 22 '09 at 19:22 2009-11-22 19:22
source share