Skip to content

Commit cef7be5

Browse files
authored
Attempt to raise Acrolinx score to 80
1 parent da66290 commit cef7be5

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

docs/cpp/initializers.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Initializers may take these forms:
6464

6565
## Kinds of initialization
6666

67-
There are several kinds of initialization, which may occur at different points in program execution. Different kinds of initialization are not mutually exclusive—for example, list initialization can trigger value initialization and in other circumstances, it can trigger aggregate initialization.
67+
There are several kinds of initialization, which may occur at different points in program execution. Different kinds of initialization aren't mutually exclusive—for example, list initialization can trigger value initialization and in other circumstances, it can trigger aggregate initialization.
6868

6969
### Zero initialization
7070

@@ -114,27 +114,27 @@ MyClass mc1;
114114
MyClass* mc3 = new MyClass;
115115
```
116116

117-
If the class, struct, or union does not have a default constructor, the compiler emits an error.
117+
If the class, struct, or union doesn't have a default constructor, the compiler emits an error.
118118

119-
Scalar variables are default initialized when they are defined with no initialization expression. They have indeterminate values.
119+
Scalar variables are default initialized when they're defined with no initialization expression. They have indeterminate values.
120120

121121
```cpp
122122
int i1;
123123
float f;
124124
char c;
125125
```
126126

127-
Arrays are default initialized when they are defined with no initialization expression. When an array is default-initialized, its members are default initialized and have indeterminate values, as in the following example:
127+
Arrays are default initialized when they're defined with no initialization expression. When an array is default-initialized, its members are default initialized and have indeterminate values, as in the following example:
128128

129129
```cpp
130130
int int_arr[3];
131131
```
132132

133-
If the array members do not have a default constructor, the compiler emits an error.
133+
If the array members don't have a default constructor, the compiler emits an error.
134134

135135
#### Default initialization of constant variables
136136

137-
Constant variables must be declared together with an initializer. If they are scalar types they cause a compiler error, and if they are class types that have a default constructor they cause a warning:
137+
Constant variables must be declared together with an initializer. If they're scalar types they cause a compiler error, and if they're class types that have a default constructor they cause a warning:
138138

139139
```cpp
140140
class MyClass{};
@@ -249,10 +249,10 @@ int main() {
249249
}
250250
```
251251

252-
Copy initialization cannot invoke explicit constructors.
252+
Copy initialization can't invoke explicit constructors.
253253

254254
```cpp
255-
vector<int> v = 10; // the constructor is explicit; compiler error C2440: cannot convert from 'int' to 'std::vector<int,std::allocator<_Ty>>'
255+
vector<int> v = 10; // the constructor is explicit; compiler error C2440: can't convert from 'int' to 'std::vector<int,std::allocator<_Ty>>'
256256
regex r = "a.*b"; // the constructor is explicit; same error
257257
shared_ptr<int> sp = new int(1729); // the constructor is explicit; same error
258258
```
@@ -422,7 +422,7 @@ myArr3: 8 9 10 0 0
422422

423423
#### Initializing unions and structs
424424

425-
If a union does not have a constructor, you can initialize it with a single value (or with another instance of a union). The value is used to initialize the first non-static field. This is different from struct initialization, in which the first value in the initializer is used to initialize the first field, the second to initialize the second field, and so on. Compare the initialization of unions and structs in the following example:
425+
If a union doesn't have a constructor, you can initialize it with a single value (or with another instance of a union). The value is used to initialize the first non-static field. This is different from struct initialization, in which the first value in the initializer is used to initialize the first field, the second to initialize the second field, and so on. Compare the initialization of unions and structs in the following example:
426426
427427
```cpp
428428
struct MyStruct {
@@ -488,7 +488,7 @@ int main()
488488
}
489489
```
490490

491-
The only way to initialize a reference with a temporary object is to initialize a constant temporary object. Once initialized, a reference-type variable always points to the same object; it cannot be modified to point to another object.
491+
The only way to initialize a reference with a temporary object is to initialize a constant temporary object. Once initialized, a reference-type variable always points to the same object; it can't be modified to point to another object.
492492

493493
Although the syntax can be the same, initialization of reference-type variables and assignment to reference-type variables are semantically different. In the preceding example, the assignments that change `iVar` and `lVar` look similar to the initializations, but have different effects. The initialization specifies the object to which the reference-type variable points; the assignment assigns to the referred-to object through the reference.
494494

@@ -527,10 +527,10 @@ The decision graph begins with: is the initializer an lvalue of the same type or
527527
:::image-end:::
528528
Decision graph for initialization of reference types
529529
530-
References to **`volatile`** types (declared as **`volatile`** *typename*<strong>&</strong> *identifier*) can be initialized with **`volatile`** objects of the same type or with objects that have not been declared as **`volatile`**. They cannot, however, be initialized with **`const`** objects of that type. Similarly, references to **`const`** types (declared as **`const`** *typename*<strong>&</strong> *identifier*) can be initialized with **`const`** objects of the same type (or anything that has a conversion to that type or with objects that have not been declared as **`const`**). They cannot, however, be initialized with **`volatile`** objects of that type.
530+
References to **`volatile`** types (declared as **`volatile`** *typename*<strong>&</strong> *identifier*) can be initialized with **`volatile`** objects of the same type or with objects that haven't been declared as **`volatile`**. They can't, however, be initialized with **`const`** objects of that type. Similarly, references to **`const`** types (declared as **`const`** *typename*<strong>&</strong> *identifier*) can be initialized with **`const`** objects of the same type (or anything that has a conversion to that type or with objects that haven't been declared as **`const`**). They can't, however, be initialized with **`volatile`** objects of that type.
531531
532-
References that are not qualified with either the **`const`** or **`volatile`** keyword can be initialized only with objects declared as neither **`const`** nor **`volatile`**.
532+
References that aren't qualified with either the **`const`** or **`volatile`** keyword can be initialized only with objects declared as neither **`const`** nor **`volatile`**.
533533

534534
### Initialization of external variables
535535

536-
Declarations of automatic, static, and external variables can contain initializers. However, declarations of external variables can contain initializers only if the variables are not declared as **`extern`**.
536+
Declarations of automatic, static, and external variables can contain initializers. However, declarations of external variables can contain initializers only if the variables aren't declared as **`extern`**.

0 commit comments

Comments
 (0)