S
subramanian100in
Is it advisable to open a file in a ctor ? Or should a file be opened
in a member function ? The reason for asking this question is the
following:
If we open the file in a ctor, then the dtor may have to close the
file. However closing a file can fail and a dtor should not perform an
operation that can fail. So a file should not be closed in a dtor but
instead it should be closed in a member function. Similarly should a
file be opened in a member function ?
Kindly explain.
Thanks
V.Subramanian
in a member function ? The reason for asking this question is the
following:
If we open the file in a ctor, then the dtor may have to close the
file. However closing a file can fail and a dtor should not perform an
operation that can fail. So a file should not be closed in a dtor but
instead it should be closed in a member function. Similarly should a
file be opened in a member function ?
Kindly explain.
Thanks
V.Subramanian