Skip to content

Commit 737e1df

Browse files
author
Michael Blome
committed
more formatting through end
1 parent 122bbb4 commit 737e1df

33 files changed

+81
-97
lines changed

docs/cpp/templates-cpp.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ T minimum(const T& lhs, const T& rhs)
3030
3131
Elsewhere, a user can declare an instance of the template that is specialized for int. Assume that get_a() and get_b() are functions that return an int:
3232
33-
```
33+
```cpp
3434
int a = get_a();
3535
int b = get_b();
3636
int i = minimum<int>(a, b);
@@ -44,7 +44,7 @@ int i = minimum(a, b);
4444

4545
When the compiler encounters that last statement, it generates a new function in which every occurrence of *T* in the template is replaced with `int`:
4646

47-
```
47+
```cpp
4848

4949
int minimum(const int& lhs, const int& rhs)
5050
{
@@ -66,7 +66,7 @@ template <typename T, typename U, typename V> class Foo{};
6666

6767
The keyword `class` is equivalent to `typename` in this context. You can express the previous example as:
6868

69-
```
69+
```cpp
7070
template <class T, class U, class V> class Foo{};
7171
```
7272
@@ -103,7 +103,7 @@ int main()
103103

104104
There is no inherent requirement that the type arguments for any particular template all belong to the same object hierarchy, although you can define a template that enforces such a restriction. You can combine object-oriented techniques with templates; for example, you can store a Derived* in a vector\<Base\*>. Note that the arguments must be pointers
105105

106-
```
106+
```cpp
107107
vector<MyClass*> vec;
108108
MyDerived d(3, L"back again", time(0));
109109
vec.push_back(&d);
@@ -118,7 +118,7 @@ vector<MyClass*> vec;
118118
## Non-type parameters
119119
Unlike generic types in other languages such as C# and Java, C++ templates support non-type parameters, also called value parameters. For example, you can provide a constant integral value to specify the length of an array, as with this example that is similar to the std::array class in the Standard Library:
120120
121-
```
121+
```cpp
122122
template<typename T, size_t L>
123123
class MyArray
124124
{

docs/cpp/temporary-objects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ In some cases, it is necessary for the compiler to create temporary objects. The
1818

1919
- To store the return value of a function that returns a user-defined type. These temporaries are created only if your program does not copy the return value to an object. For example:
2020

21-
```
21+
```cpp
2222
UDT Func1(); // Declare a function that returns a user-defined
2323
// type.
2424

docs/cpp/this-pointer.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@ The **this** pointer is a pointer accessible only within the nonstatic member fu
1919

2020
```
2121
22-
this 
22+
this 
2323
this->member-identifier
2424
```
2525

2626
## Remarks
2727
An object's **this** pointer is not part of the object itself; it is not reflected in the result of a `sizeof` statement on the object. Instead, when a nonstatic member function is called for an object, the address of the object is passed by the compiler as a hidden argument to the function. For example, the following function call:
2828

29-
```
29+
```cpp
3030
myDate.setMonth( 3 );
3131
```
3232

3333
can be interpreted this way:
3434

35-
```
35+
```cpp
3636
setMonth( &myDate, 3 );
3737
```
3838
3939
The object's address is available from within the member function as the **this** pointer. Most uses of **this** are implicit. It is legal, though unnecessary, to explicitly use **this** when referring to members of the class. For example:
4040
41-
```
41+
```cpp
4242
void Date::setMonth( int mn )
4343
{
4444
month = mn; // These three statements
@@ -49,13 +49,13 @@ void Date::setMonth( int mn )
4949

5050
The expression `*this` is commonly used to return the current object from a member function:
5151

52-
```
52+
```cpp
5353
return *this;
5454
```
5555

5656
The **this** pointer is also used to guard against self-reference:
5757

58-
```
58+
```cpp
5959
if (&Object != this) {
6060
// do not execute in cases of self-reference
6161
```
@@ -67,7 +67,7 @@ if (&Object != this) {
6767
6868
## Example
6969
70-
```
70+
```cpp
7171
// this_pointer.cpp
7272
// compile with: /EHsc
7373
@@ -140,7 +140,7 @@ your buffer
140140

141141
Consider this example:
142142

143-
```
143+
```cpp
144144
// type_of_this_pointer1.cpp
145145
class Point
146146
{
@@ -153,7 +153,7 @@ int main()
153153

154154
The preceding code declares a member function, `X`, in which the **this** pointer is treated as a **const** pointer to a **const** object. Combinations of *cv-mod-list* options can be used, but they always modify the object pointed to by **this**, not the **this** pointer itself. Therefore, the following declaration declares function `X`; the **this** pointer is a **const** pointer to a **const** object:
155155

156-
```
156+
```cpp
157157
// type_of_this_pointer2.cpp
158158
class Point
159159
{

docs/cpp/tokens-cpp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ A token is the smallest element of a C++ program that is meaningful to the compi
3232

3333
The parser separates tokens from the input stream by creating the longest token possible using the input characters in a left-to-right scan. Consider this code fragment:
3434

35-
```
35+
```cpp
3636
a = i+++j;
3737
```
3838

3939
The programmer who wrote the code might have intended either of these two statements:
4040

41-
```
41+
```cpp
4242
a = i + (++j)
4343

4444
a = (i++) + j

docs/cpp/transfers-of-control.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ You can use the `goto` statement or a **case** label in a `switch` statement to
1616

1717
The following example shows a loop that declares and initializes the objects `total`, `ch`, and `i`. There is also an erroneous `goto` statement that transfers control past an initializer.
1818

19-
```
19+
```cpp
2020
// transfers_of_control.cpp
2121
// compile with: /W1
2222
// Read input until a nonnumeric character is entered.

docs/cpp/true-cpp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ms.workload: ["cplusplus"]
1717

1818
```
1919
20-
bool-identifier = true ;
20+
bool-identifier = true ;
2121
bool-expression logical-operator true ;
2222
```
2323

@@ -26,7 +26,7 @@ bool-expression logical-operator true ;
2626

2727
## Example
2828

29-
```
29+
```cpp
3030
// bool_true.cpp
3131
#include <stdio.h>
3232
int main()

docs/cpp/try-except-statement.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ int main()
148148

149149
## Output
150150

151-
```
151+
```Output
152152
hello
153153
in try
154154
in try

docs/cpp/try-finally-statement.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ms.workload: ["cplusplus"]
1717

1818
The following syntax describes the `try-finally` statement:
1919

20-
```
20+
```cpp
2121
__try {
2222
// guarded code
2323
}

docs/cpp/try-throw-and-catch-statements-cpp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ To implement exception handling in C++, you use `try`, `throw`, and `catch` expr
2525

2626
## Example
2727

28-
```
28+
```cpp
2929

3030
MyData md;
3131
try {
@@ -63,7 +63,7 @@ MyData GetNetworkResource()
6363

6464
A `throw` expression that has no operand re-throws the exception currently being handled. We recommend this form when re-throwing the exception, because this preserves the original exception’s polymorphic type information. Such an expression should only be used in a `catch` handler or in a function that's called from a `catch` handler. The re-thrown exception object is the original exception object, not a copy.
6565

66-
```
66+
```cpp
6767
try {
6868
   throw CSomeOtherException();
6969
}

docs/cpp/typeid-operator.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ ms.workload: ["cplusplus"]
1616

1717
```
1818
19-
typeid(
20-
type-id
21-
)
22-
typeid( expression )
19+
typeid(type-id)
20+
typeid(expression)
2321
```
2422

2523
## Remarks
@@ -39,7 +37,7 @@ typeid( expression )
3937

4038
If the *expression* points to a base class type, yet the object is actually of a type derived from that base class, a **type_info** reference for the derived class is the result. The *expression* must point to a polymorphic type (a class with virtual functions). Otherwise, the result is the **type_info** for the static class referred to in the *expression*. Further, the pointer must be dereferenced so that the object it points to is used. Without dereferencing the pointer, the result will be the **type_info** for the pointer, not what it points to. For example:
4139

42-
```
40+
```cpp
4341
// expre_typeid_Operator.cpp
4442
// compile with: /GR /EHsc
4543
#include <iostream>
@@ -68,7 +66,7 @@ int main() {
6866
6967
If the *expression* is neither a pointer nor a reference to a base class of the object, the result is a **type_info** reference representing the static type of the *expression*. The *static type* of an expression refers to the type of an expression as it is known at compile time. Execution semantics are ignored when evaluating the static type of an expression. Furthermore, references are ignored when possible when determining the static type of an expression:
7068
71-
```
69+
```cpp
7270
// expre_typeid_Operator_2.cpp
7371
#include <typeinfo>
7472
@@ -80,7 +78,7 @@ int main()
8078

8179
**typeid** can also be used in templates to determine the type of a template parameter:
8280

83-
```
81+
```cpp
8482
// expre_typeid_Operator_3.cpp
8583
// compile with: /c
8684
#include <typeinfo>

0 commit comments

Comments
 (0)