TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: THOMAS MAEDER
from: ROGER SCUDDER
date: 1998-02-06 02:03:00
subject: C++ Saveding stuff

Hello Thomas.
03 Feb 98 17:08, Thomas Maeder wrote to Roger Scudder:
RS>> TM>     if (name=="Cyber Con")
RS>>  That doesn't work.  You're comparing addresses.  Use strcmp.
TM> No. I call an overloaded operator==().
 And you expect a complete novice to understand that without
 even a comment?   I assumed that this would be your response,
 but I think you should provide the code for the overloaded
 operator if you are going to present such an advanced OO
 technique to a novice.
RS>> TM>         cout >> "Hi Cyber Con";
RS>> TM>     ofstream("file1.fil") << name;
RS>>  You have to open the file before you can write to it.
TM> No. The ofstream constructor does that.
 Oh, really?  I don't doubt it can be done, but is that the
 default or does that have to be implemented by you?
RS>> TM> }
RS>>  And close it when you're done
TM> No. The ofstream destructor does that.
 Sounds like sloppy programming to me, but then I'm very new
 to the C++.  I feel that IO cleanup should be done explicitly.
 In my opinion, files should
 always be closed explicitly.
 Here's the errors I get when I try to compile your code.
Error test.cpp 2: Unable to open include file 'cstring.h' Error test.cpp 8: 
Undefined symbol 'string' in function main(int,char * *) Error test.cpp 8: 
Statement missing ; in function main(int,char * *) Error test.cpp 9: 
Undefined symbol 'name' in function main(int,char * *) Error test.cpp 12: 
Illegal structure operation in function main(int,char * *) Warning test.cpp 
15: Function should return a value in function main(int,char * *)
 -Roger
... 'If it ain't broke, you can probably still fix it.' - Tim Allen
--- Msged 4.20 beta 3
(1:273/404@fidonet)
---------------
* Origin: Hodge-Podge Support BBS, Upper Darby, Pennsylvania, USA

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™.