C (49/178)

From:Alexander Niven-Jenkins
Date:14 Jul 2000 at 18:43:26
Subject:Re: overloading operators

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 );
}

Is that what you mean? All you need to do is override the << operator
for all the different types you want.

Kind regards...

Alex



Cremlin Software - http://www.cremlinsoftware.org
Founder, lead programmer - ghandi@cremlinsoftware.org
Production, programmer - anj@cremlinsoftware.org

------------------------------------------------------------------------
The Most Expensive Thing You Can Haul Is An Empty Trailer.
http://click.egroups.com/1/5776/1/_/451227/_/963597031/
------------------------------------------------------------------------