Content deleted Content added
This is true for satically typed langs; in the rest it's handled dynamically by interpreter/compiler |
formatting |
||
Line 96:
Another typical example is interacting with files: We could have an object that represents a file that is open for writing, wherein the file is opened in the constructor and closed when execution leaves the object's scope. In both cases, RAII ensures only that the resource in question is released appropriately; care must still be taken to maintain exception safety. If the code modifying the data structure or file is not exception-safe, the mutex could be unlocked or the file closed with the data structure or file corrupted.
Ownership of dynamically allocated objects (memory allocated with <
== Clang and GCC "cleanup" extension for C ==
|