TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: BENJAMIN L MCGEE
from: BALOG PAL
date: 1997-08-17 07:05:00
subject: replies here -[]

                            Hi, Benjamin L Mcgee!
On 13 Aug 97  23:14:00 you wrote to All
 BLM> How would you define "ascribing to much responsibility to the
 BLM> constructor?"  Is this to much...
 BLM>
 BLM> manifest::manifest(){
 BLM> filename = new char[FILENAME_MAX];
 BLM> while (!select(filename, FILENAME_MAX - 1));
 BLM> mstreamp = new ifstream(filename);
 BLM> }
Depends on what you want of it.
I see no good reason to create an ifstream on the fly. You can simply have a
member of type ifstream in your class, that will save a heap operation (and
another in dtor). filename is also questionable is you use a platform tith
nonlimited stack.
Is select is a user-interfaced function, it really can be misplaced in the
ctor. There can be situations where you want to instantiate the class but not
immediately use it. Then you better leave the filename not selectes right in
the ctor, but in a separate member function. But these all depensd on the
purpose of the class.
Paul
... Beware of programmers who carry screwdrivers
--- OS/2 Warp
---------------
* Origin: The FlintStones' Cave in BedRock (2:371/20)

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