You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This section explains concepts that are critical to understanding C++. C programmers will be familiar with many of these concepts, but there are some subtle differences that can cause unexpected program results. The following topics are included:
11
11
12
12
-[C++ type system](cpp-type-system-modern-cpp.md)
13
-
14
-
-[Declarations and definitions](../cpp/declarations-and-definitions-cpp.md)
15
-
16
-
-[Scope of a C++ object or function](../cpp/scope-visual-cpp.md)
17
-
18
-
-[Program definition and linkage rules](../cpp/program-and-linkage-cpp.md)
19
-
20
-
-[Startup and termination](../cpp/startup-and-termination-cpp.md)
21
-
22
-
-[L-values and r-values](../cpp/lvalues-and-rvalues-visual-cpp.md)
Copy file name to clipboardExpand all lines: docs/cpp/declarations-and-definitions-cpp.md
+14-2Lines changed: 14 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
---
2
-
title: "Declarations and Definitions (C++)"
2
+
title: "Declarations and definitions (C++)"
3
3
ms.date: "12/12/2019"
4
4
ms.assetid: 678f1424-e12f-45e0-a957-8169e5fef6cb
5
5
---
6
-
# Declarations and Definitions (C++)
6
+
# Declarations and definitions (C++)
7
7
8
8
A C++ program consists of various entities such as variables, functions, types, and namespaces. Each of these entities must be *declared* before they can be used. A declaration specifies a unique name for the entity, along with information about its type and other characteristics. In C++ the point at which a name is declared is the point at which it becomes visible to the compiler. You cannot refer to a function or class that is declared at some later point in the compilation unit. Variables should be declared as close as possible before the point at which they are used.
9
9
@@ -88,6 +88,18 @@ Because static class data members are discrete variables shared by all objects o
88
88
89
89
A C++ program might contain more than one [compilation unit](header-files-cpp.md). To declare an entity that is defined in a separate compilation unit, use the [extern](extern-cpp.md) keyword. The information in the declaration is sufficient for the compiler, but if the definition of the entity cannot be found in the linking step, then the linker will raise an error.
This section introduces the fundamental elements of a C++ program. You use these elements, called "lexical elements" or "tokens" to construct statements, definitions, declarations, and so on, which are used to construct complete programs. The following lexical elements are discussed in this section:
11
12
12
-
-[Tokens and character Sets](../cpp/character-sets.md)
13
+
-[Tokens and character sets](../cpp/character-sets.md)
13
14
-[Comments](../cpp/comments-cpp.md)
14
15
-[Identifiers](../cpp/identifiers-cpp.md)
15
16
-[Keywords](../cpp/keywords-cpp.md)
16
17
-[Punctuators](../cpp/punctuators-cpp.md)
17
-
-[Numeric, Boolean, and Pointer Literals](../cpp/numeric-boolean-and-pointer-literals-cpp.md)
18
-
-[String and Character Literals](../cpp/string-and-character-literals-cpp.md)
Copy file name to clipboardExpand all lines: docs/cpp/welcome-back-to-cpp-modern-cpp.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ Whenever possible, use a smart pointer when allocating heap memory. If you must
41
41
42
42
## std::string and std::string_view
43
43
44
-
C-style strings are another major source of bugs. By using [std::string and std::wstring](../standard-library/basic-string-class.md) you can eliminate virtually all the errors associated with C-style strings, and gain the benefit of member functions for searching, appending, prepending, and so on. Both are highly optimized for speed. When passing a string to a function that requires only read-only access, in (C++17) you can use [std::string_view](../standard-library/basic-string-view-class.md) for even greater performance benefit.
44
+
C-style strings are another major source of bugs. By using [std::string and std::wstring](../standard-library/basic-string-class.md) you can eliminate virtually all the errors associated with C-style strings, and gain the benefit of member functions for searching, appending, prepending, and so on. Both are highly optimized for speed. When passing a string to a function that requires only read-only access, in C++17 you can use [std::string_view](../standard-library/basic-string-view-class.md) for even greater performance benefit.
45
45
46
46
## std::vector and other Standard Library containers
0 commit comments