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