From: | James S. Adelman |
Date: | 15 Jul 2000 at 10:17:00 |
Subject: | Re: overloading operators |
[amiga-c] Re: overloading operators wrote on Fri, 14 Jul 2000 18:43:26 +0100 in <yam8230.1325.1172578000@smtp.freeserve.net> :
> Hiya Johan,
>
> On 14-Jul-00, you wrote:
>
> > int i = 23;
> > char *b = "hello";
>
> > myprintclass << "hi " << b << ", test " << i;
>
> > and have myprintclass launch the apropriate functions?
>
> I guess, off the to of my head I can't think what the return type of<<
> is, if there is one, but I think it would be done as?
>
> rettype myprintclass :: operator << ( const char* &rhs ) const
> {
> out( rhs );
> }
>
> rettype myprintclass :: operator << ( const int &rhs ) const
> {
> out( rhs );
> }
Not quite, operators have implicit return types, so you cannot declare
or define them with any return-type (not even void).
------------------------------------------------------------------------
It's the End Of The Line for My Shipping Broker.
http://click.egroups.com/1/5175/1/_/451227/_/963757267/
------------------------------------------------------------------------