Skip to content

Commit 953a036

Browse files
authored
Update 05-pointers.md
1 parent c746120 commit 953a036

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

book/en-us/05-pointers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The basic idea is to count the number of dynamically allocated objects. Whenever
1515
Each time a reference is deleted, the reference count is decremented by one. When the reference count of an object is reduced to zero, the pointed heap memory is automatically deleted.
1616

1717
In traditional C++, "remembering" to manually release resources is not always a best practice. Because we are likely to forget to release resources and lead to leakage.
18-
So the usual practice is that for an object, we apply for space when constructor, and free space when the destructor (called when leaving the scope).
18+
So the usual practice is that for an object, we apply for space when constructed, and free space when the destructed (called when leaving the scope).
1919
That is, we often say that the RAII resource acquisition is the initialization technology.
2020

2121
There are exceptions to everything, we always need to allocate objects on free storage. In traditional C++ we have to use `new` and `delete` to "remember" to release resources. C++11 introduces the concept of smart pointers, using the idea of ​​reference counting so that programmers no longer need to care about manually releasing memory.

0 commit comments

Comments
 (0)