-
Directly from the auto_ptr class of the <memory> header in my STL implementation:
Code:
/**
* @brief Smart pointer dereferencing.
*
* This returns the pointer itself, which the language then will
* automatically cause to be dereferenced.
*/
element_type*
operator->() const throw() { return _M_ptr; }
-
Code:
template<typename Y>
class UselessExample
{
public:
Y* operator ->() { return ptr_;}
Y& operator *() { return *ptr_;}
private:
Y* ptr_;
};
There you go.
-
Stroustrup's C++PL, Special Edition, p. 262.
The only one's which cannot be redefined are '::', '.', and '.*'. Of course, '?:' can't be either, but its sort of a weird 'operator' anyways.