Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
By default, smart pointers call delete (or delete[]) upon destruction. However, when interfacing with legacy C libraries (POSIX sockets, C file pointers FILE*, OpenSSL context handles, Win32 handles), cleanup requires custom routines like fclose() or free(). Modern C++ allows binding custom deleters to smart pointers.
FILE* in std::unique_ptrstd::shared_ptrUnlike unique_ptr (where the deleter type is part of the template signature), std::shared_ptr performs type erasure on deleters, allowing clean inline lambda deleters:
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| std::weak_ptr: Breaking Circular References and Observer Patterns | Function Templates and Class Templates |
Test your understanding of this lesson with 1 questions. Each question has one correct answer.