If you really need to use delete, you can use some wrappers around these constructs. How,
class MyFILE { public: MyFILE(); virtual ~MyFILE(){fclose(_fileptr); private: FILE * _fileptr; }
Using an example will
MyFILE * f = new MyFILE(); delete f;
Personally, I prefer this shell solution, as it provides an exhaustive way to manage resources. For example, when we are on a code segment where exceptions can be thrown at any time on any part of it. If we allocate resources, such as open files, this mechanism opens the way to βautomaticallyβ delete the object when the shell goes out of scope.
Doonyx
source share