quote:
Original post by foofightr
Maybe you haven't heard, but C doesn't have constructors.
C doesn't allow to create variables anywhere either, but since this is a C++ thread it doesn't matter
The example was in response to your statement:
quote:
The only use I can see of this C++ feature (declaring vars virtually anywhere) is that it helps code readability
Which is true for basic types, but most C++ programs have user defined types with sometimes complicated constructors.
quote:
However, you do have a point about the "slow resources" stuff. I wouldn't do things this way however.
I almost always use a construct to allocate resources (memory, files, etc) and free them in the destructor. It keeps my code exception safe and avoids any messy 'tidy up' code at the end of a function.
Edited by - Wilka on July 17, 2000 6:20:09 PM