Skip to content

Commit b947343

Browse files
author
mikeblome
committed
improved wording
1 parent 1f0afd6 commit b947343

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

docs/cpp/pointers-cpp.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
---
22
title: "Pointers (C++)"
3-
ms.date: "11/08/2019"
3+
ms.date: "11/13/2019"
44
description: "About raw pointers and smart pointers in Microsoft C++."
55
helpviewer_keywords: ["pointers (C++)"]
66
ms.assetid: 595387c5-8e58-4670-848f-344c7caf985e
77
---
88

99
# Pointers (C++)
1010

11-
A pointer is a variable that stores the memory address of an object. Pointers are used extensively in both C and C++ for three purposes:
11+
A pointer is a variable that stores the memory address of an object. Pointers are used extensively in both C and C++ for three main purposes:
1212

1313
1. to allocate new objects on the heap,
14-
2. to pass larger objects to functions,
15-
3. to pass functions to other functions
16-
4. to iterate over elements in arrays or other data structures.
14+
1. to pass functions to other functions
15+
1. to iterate over elements in arrays or other data structures.
1716

18-
In C-style programming, *raw pointers* are used for all these scenarios. However, pointer errors are by far the greatest cause of crashes, hangs, data corruption, security holes, and general programmer misery. In modern C++, the use of *raw pointers* is strongly discouraged except in scenarios where they provide a significant performance benefit. Modern C++ provides *smart pointers* for allocating objects, *iterators* for traversing data structures, and *lambda expressions* for passing functions. By using these language and library facilities instead of raw pointers, you will make your program safer, easier to debug, and simpler to understand and maintain. See [Smart pointers](smart-pointers-modern-cpp.md), [Iterators](../standard-library/iterators.md), and [Lambda expressions](lambda-expressions-in-cpp.md) for more information.
17+
In C-style programming, *raw pointers* are used for all these scenarios. However, raw pointers are the source of many serious programming errors. Therefore, their use is strongly discouraged except where they provide a significant performance benefit and there is no ambiguity as to which pointer is the *owning pointer* that is responsible for deleting the object. Modern C++ provides *smart pointers* for allocating objects, *iterators* for traversing data structures, and *lambda expressions* for passing functions. By using these language and library facilities instead of raw pointers, you will make your program safer, easier to debug, and simpler to understand and maintain. See [Smart pointers](smart-pointers-modern-cpp.md), [Iterators](../standard-library/iterators.md), and [Lambda expressions](lambda-expressions-in-cpp.md) for more information.
1918

2019
## In this section
2120

@@ -32,4 +31,3 @@ In C-style programming, *raw pointers* are used for all these scenarios. However
3231

3332
[Iterators](../standard-library/iterators.md)
3433
[Lambda expressions](lambda-expressions-in-cpp.md)
35-

0 commit comments

Comments
 (0)