Skip to content

Commit b988817

Browse files
authored
Address feedback given
1 parent 7064942 commit b988817

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

docs/cpp/destructors-cpp.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ Destructors are called when one of the following events occurs:
7171
7272
- A local (automatic) object with block scope goes out of scope.
7373
74-
- An object allocated using the **`new`** or **`new[]`** operator is explicitly deallocated using **`delete`** or **`delete[]`**.
74+
- An object allocated using the **`new`** operator is explicitly deallocated using **`delete`**. If **`delete[]`** is used instead, it would result in undefined behaviour.
75+
76+
- Objects allocated using the **`new[]`** operator is explicitly deallocated using **`delete[]`**. If **`delete`** is used instead, it would result in undefined behaviour.
7577
7678
- The lifetime of a temporary object ends.
7779
@@ -123,8 +125,10 @@ int main() {
123125
B3 * b2 = new B3;
124126
delete b2;
125127
}
128+
```
126129

127-
/* Output: A3 dtor
130+
```output
131+
A3 dtor
128132
A2 dtor
129133
A1 dtor
130134
@@ -133,7 +137,6 @@ B1 dtor
133137
B3 dtor
134138
B2 dtor
135139
B1 dtor
136-
*/
137140
```
138141

139142
### Virtual base classes

0 commit comments

Comments
 (0)