Skip to content

Commit 54506ab

Browse files
author
mikeblome
committed
fixed heading and text placemewnt
1 parent 04e7bfd commit 54506ab

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

docs/cpp/program-termination.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ The `exit` and **return** statements in the preceding example are functionally i
4646

4747
When you call `exit` or execute a **return** statement from `main`, static objects are destroyed in the reverse order of their initialization (after the call to `atexit` if one exists). The following example shows how such initialization and cleanup works.
4848

49-
## Example
49+
### Example
50+
51+
In the following example, the static objects `sd1` and `sd2` are created and initialized before entry to `main`. After this program terminates using the **return** statement, first `sd2` is destroyed and then `sd1`. The destructor for the `ShowData` class closes the files associated with these static objects.
5052

5153
```cpp
5254
// using_exit_or_return1.cpp
@@ -84,8 +86,6 @@ int main() {
8486
}
8587
```
8688
87-
In the preceding example, the static objects `sd1` and `sd2` are created and initialized before entry to `main`. After this program terminates using the **return** statement, first `sd2` is destroyed and then `sd1`. The destructor for the `ShowData` class closes the files associated with these static objects.
88-
8989
Another way to write this code is to declare the `ShowData` objects with block scope, allowing them to be destroyed when they go out of scope:
9090
9191
```cpp

0 commit comments

Comments
 (0)