"Suman" <sk*****@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Having had a look at the C++ FAQ, comp.lang.c++ & comp.std.c++
archives and Stroustrup's FAQs (particularly the following:
<url:http://www.research.att.com/~bs/bs_faq2.html#overload-dot/>)
I am left to wondering why Stroustrup doesn't mention the
*_cast<> operators or operator .* in that particular FAQ.
Archived discussions have convinced me that .* _cannot_ be overloaded.
I have gathered a notion (perhaps incorrectly) that the *_cast<>
operators cannot be overloaded as well. Hence this post.
Awaiting enlightenment.
Well, aren't we all? ;-)
You cannot directly overload "operators" like static_cast<> but what you can
do is to overload the conversion operators that are invoked upon the use of
a cast. For example:
class MyString {
public:
.....
operator char*(); // Here you could implement the desired behavior when
a cast to char* is required.
}
But you should be very careful with this, as sometimes casting might be
performed implicitely and this can open Pandora's box!!
The operator ".*" cannot be overloaded at all.
HTH
Chris