TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALL
from: JAMIE KOWINSKY
date: 1997-09-16 22:32:00
subject: cout`ing an object

Have a question for all you C++ pros out there.
say I have a class defined, lets call it class test, this class has a number
of private variables and public functions.  It includes a function to
print out some private data fileds ex "void test:print(void)" this
function simply does "cout << stuff" on a number of things, in effect 
rinting
the fields of the object.
Now say i have some object created with this class ex:
test thing = test(....);
normally to print this thing i have to call "thing.print" I would rather
do a "cout << thing".  I am fimular with overloading operators, and I would
like to know if its possible to overload the << operator somehow to do this.
Or perhaps there is another way.
Thanks for any help (Oh, I;m using Turbo C++ 4.5 if it matters)
l8tr
-Jamie
... Anything not nailed down is mine.  Anything I pry loose is not nailed
--- FMail/386 1.02
---------------
* Origin: KastlerocK + Jeannette, PA + 412.527.3749 (1:129/230)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.