It's basically just a pain in the neck to explain, and isn't something
that comes up often enough for people to have examples at hand. If this
is a purely academic question, Google is probably your best bet. If,
OTOH, you have a real-world situation that needs a practical answer, it
would be helpful if you could explain it.
I admit its may not a practical question since I have never overloaded
these two operators before.
That's why I am curious enough to post this thread to see if anyone
have actually had any practical usage them.
Here is my tentative code of overloading operator->*(), it works , but
its ugly. Any one know how to use it correctly?
class Base;
typedef void (Base::*PMF) (int);
class Base {
public:
void foo(int a)
{
cout << "base::foo" << endl;
}
void operator->*(PMF p)
{
cout << "ponter to member operator overloaded" << endl;
(this->*p)(1);
}
};
int main()
{
PMF pmf;
Base b;
pmf = &Base::foo;
Base* pb = &b;
pb->operator->*(pmf); //here my overloading operator->* has been
called, but its ugly
(pb->*pmf)(1); //why this doesn't invoke my overloaded operator-
return 0;
}
Thanks.
Gob00st