Alf P. Steinbach wrote:
* Victor Bazarov:
>>
Stand-alone functions are better than members of the class deriving
from the standard class. At least with those you could expect
application of conversions (standard and user-defined).
Huh?
If you have a function that can uppercase a string, it's better if you
make it a non-member because a class that defines a conversion to a
string, cannot be used with a member.
Consider
class M {};
void foo(M&);
class L { public: operator M&(); };
versus
class M { public: foo(); };
class L { public: operator M&(); };
With the former you can have
L l;
foo(l);
but with the latter you can't do
L l;
l.foo();
>
Consider
struct M {};
void foo( M& );
versus
struct M { void foo(); };
With the former you can write
M o;
foo( o );
With the latter you can write
M().foo();
If foo is an operator like << this can be of practical significance.
Huh?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask