Skip to content

Commit d67790d

Browse files
author
Michael Blome
committed
more formatting
1 parent cadae48 commit d67790d

14 files changed

Lines changed: 42 additions & 46 deletions

docs/cpp/final-specifier.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ You can use the `final` keyword to designate virtual functions that cannot be ov
2020
```
2121
2222
function-declaration final;
23-
```
24-
25-
```
26-
2723
class class-name final base-classes
2824
```
2925

docs/cpp/function-call-cpp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ primary-expression ( expression-list )
2626

2727
The function-call operator, when overloaded, does not modify how functions are called; rather, it modifies how the operator is to be interpreted when applied to objects of a given class type. For example, the following code would usually be meaningless:
2828

29-
```
29+
```cpp
3030
Point pt;
3131
pt( 3, 2 );
3232
```
3333
3434
Given an appropriate overloaded function-call operator, however, this syntax can be used to offset the `x` coordinate 3 units and the `y` coordinate 2 units. The following code shows such a definition:
3535
36-
```
36+
```cpp
3737
// function_call.cpp
3838
class Point
3939
{

docs/cpp/function-call-operator-parens.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,33 @@ postfix-expression
3030

3131
- Function returning type `T`. An example declaration is
3232

33-
```
33+
```cpp
3434
T func( int i )
3535
```
3636

3737
- Pointer to a function returning type `T`. An example declaration is
3838

39-
```
39+
```cpp
4040
T (*func)( int i )
4141
```
4242

4343
- Reference to a function returning type `T`. An example declaration is
4444

45-
```
45+
```cpp
4646
T (&func)(int i)
4747
```
4848

4949
- Pointer-to-member function dereference returning type `T`. Example function calls are
5050

51-
```
51+
```cpp
5252
(pObject->*pmf)();
5353
(Object.*pmf)();
5454
```
5555

5656
## Example
5757
The following example calls the standard library function `strcat_s` with three arguments:
5858

59-
```
59+
```cpp
6060
// expre_Function_Call_Operator.cpp
6161
// compile with: /EHsc
6262

@@ -89,7 +89,7 @@ Welcome to C++
8989
## Function call results
9090
A function call evaluates to an r-value unless the function is declared as a reference type. Functions with reference return type evaluate to l-values, and can be used on the left side of an assignment statement as follows:
9191

92-
```
92+
```cpp
9393
// expre_Function_Call_Results.cpp
9494
// compile with: /EHsc
9595
#include <iostream>
@@ -123,7 +123,7 @@ int main()
123123

124124
Functions that return class types, pointers to class types, or references to class types can be used as the left operand to member-selection operators. Therefore, the following code is legal:
125125

126-
```
126+
```cpp
127127
// expre_Function_Results2.cpp
128128
class A {
129129
public:

docs/cpp/function-overloading.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ You can overload both member functions and non-member functions. The following t
3434
## Example
3535
The following example illustrates how overloading can be used.
3636

37-
```
37+
```cpp
3838
// function_overloading.cpp
3939
// compile with: /EHsc
4040
#include <iostream>
@@ -135,17 +135,17 @@ int print(double dvalue, int prec)
135135
136136
Consider the following declarations (the functions are marked `Variant 1`, `Variant 2`, and `Variant 3`, for identification in the following discussion):
137137
138-
```
138+
```cpp
139139
Fraction &Add( Fraction &f, long l ); // Variant 1
140140
Fraction &Add( long l, Fraction &f ); // Variant 2
141141
Fraction &Add( Fraction &f, Fraction &f ); // Variant 3
142142
143143
Fraction F1, F2;
144-
```
144+
```
145145

146146
Consider the following statement:
147147

148-
```
148+
```cpp
149149
F1 = Add( F2, 23 );
150150
```
151151

@@ -160,7 +160,7 @@ F1 = Add( F2, 23 );
160160

161161
The intersection of these two sets is Variant 1. An example of an ambiguous function call is:
162162

163-
```
163+
```cpp
164164
F1 = Add( 3, 6 );
165165
```
166166

@@ -186,7 +186,7 @@ F1 = Add( 3, 6 );
186186

187187
However, the function overloading mechanism can distinguish between references that are qualified by **const** and `volatile` and references to the base type. This makes code such as the following possible:
188188

189-
```
189+
```cpp
190190
// argument_type_differences.cpp
191191
// compile with: /EHsc /W3
192192
// C4521 expected
@@ -213,7 +213,7 @@ int main() {
213213
214214
### Output
215215
216-
```
216+
```Output
217217
Over default constructor
218218
Over&
219219
Over default constructor
@@ -296,7 +296,7 @@ Multiple-Inheritance Graph Illustrating Preferred Conversions
296296

297297
User-defined conversions are applied if no built-in promotion or conversion exists. These conversions are selected on the basis of the type of the argument being matched. Consider the following code:
298298

299-
```
299+
```cpp
300300
// argument_matching1.cpp
301301
class UDC
302302
{
@@ -324,7 +324,7 @@ int main()
324324
325325
During the process of matching arguments, standard conversions can be applied to both the argument and the result of a user-defined conversion. Therefore, the following code works:
326326
327-
```
327+
```cpp
328328
void LogToFile( long l );
329329
...
330330
UDC udc;
@@ -335,7 +335,7 @@ LogToFile( udc );
335335

336336
If any user-defined conversions are required to match an argument, the standard conversions are not used when evaluating the best match. This is true even if more than one candidate function requires a user-defined conversion; in such a case, the functions are considered equal. For example:
337337

338-
```
338+
```cpp
339339
// argument_matching2.cpp
340340
// C2668 expected
341341
class UDC1
@@ -381,7 +381,7 @@ int main()
381381
382382
The `.` member-selection operator works exactly the same way, except that an implicit `&` (address-of) operator is prefixed to the object name. The following example shows how this works:
383383
384-
```
384+
```cpp
385385
// Expression encountered in code
386386
obj.name
387387
@@ -447,7 +447,7 @@ int main()
447447

448448
- `typedef` declarations do not define new types; they introduce synonyms for existing types. They do not affect the overloading mechanism. Consider the following code:
449449

450-
```
450+
```cpp
451451
typedef char * PSTR;
452452

453453
void Print( char *szToPrint );
@@ -460,14 +460,14 @@ int main()
460460

461461
- The types "array of " and "pointer to" are considered identical for the purposes of distinguishing between overloaded functions. This is true only for singly dimensioned arrays. Therefore, the following overloaded functions conflict and generate an error message:
462462

463-
```
463+
```cpp
464464
void Print( char *szToPrint );
465465
void Print( char szToPrint[] );
466466
```
467467

468468
For multiply dimensioned arrays, the second and all succeeding dimensions are considered part of the type. Therefore, they are used in distinguishing between overloaded functions:
469469

470-
```
470+
```cpp
471471
void Print( char szToPrint[] );
472472
void Print( char szToPrint[][7] );
473473
void Print( char szToPrint[][9][42] );
@@ -483,7 +483,7 @@ If the base class function is not declared as 'virtual', then the derived class
483483

484484
Block scope is strictly observed; therefore, a function declared in file scope is not in the same scope as a function declared locally. If a locally declared function has the same name as a function declared in file scope, the locally declared function hides the file-scoped function instead of causing overloading. For example:
485485

486-
```
486+
```cpp
487487
// declaration_matching1.cpp
488488
// compile with: /EHsc
489489
#include <iostream>
@@ -517,7 +517,7 @@ int main()
517517
518518
Note that the call to `Deposit` in `Account::Deposit` calls the private member function. This call is correct because `Account::Deposit` is a member function and therefore has access to the private members of the class.
519519
520-
```
520+
```cpp
521521
// declaration_matching2.cpp
522522
class Account
523523
{

docs/cpp/functions-with-variable-argument-lists-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Function declarations in which the last member of is the ellipsis (...) can tak
3131

3232
The following example shows how the macros work together with the type (declared in \<stdarg.h>):
3333

34-
```
34+
```cpp
3535
// variable_argument_lists.cpp
3636
#include <stdio.h>
3737
#include <stdarg.h>

docs/cpp/general-rules-and-limitations.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ ms.workload: ["cplusplus"]
1919

2020
- If a single module in your program contains both **dllimport** and `dllexport` declarations for the same function or object, the `dllexport` attribute takes precedence over the **dllimport** attribute. However, a compiler warning is generated. For example:
2121

22-
```
22+
```cpp
2323
__declspec( dllimport ) int i;
2424
__declspec( dllexport ) int i; // Warning; inconsistent;
2525
// dllexport takes precedence.
2626
```
2727

2828
- In C++, you can initialize a globally declared or static local data pointer or with the address of a data object declared with the **dllimport** attribute, which generates an error in C. In addition, you can initialize a static local function pointer with the address of a function declared with the **dllimport** attribute. In C, such an assignment sets the pointer to the address of the DLL import thunk (a code stub that transfers control to the function) rather than the address of the function. In C++, it sets the pointer to the address of the function. For example:
2929

30-
```
30+
```cpp
3131
__declspec( dllimport ) void func1( void );
3232
__declspec( dllimport ) int i;
3333

@@ -45,7 +45,7 @@ ms.workload: ["cplusplus"]
4545

4646
However, because a program that includes the `dllexport` attribute in the declaration of an object must provide the definition for that object somewhere in the program, you can initialize a global or local static function pointer with the address of a `dllexport` function. Similarly, you can initialize a global or local static data pointer with the address of a `dllexport` data object. For example, the following code does not generate errors in C or C++:
4747

48-
```
48+
```cpp
4949
__declspec( dllexport ) void func1( void );
5050
__declspec( dllexport ) int i;
5151

@@ -63,22 +63,22 @@ ms.workload: ["cplusplus"]
6363

6464
The compiler generates the same warning if the base class is a specialization of a class template. To work around this, mark the base-class with `dllexport`. The problem with a specialization of a class template is where to place the **__declspec(dllexport)**; you are not allowed to mark the class template. Instead, explicitly instantiate the class template and mark this explicit instantiation with `dllexport`. For example:
6565

66-
```
66+
```cpp
6767
template class __declspec(dllexport) B<int>;
6868
class __declspec(dllexport) D : public B<int> {
6969
// ...
7070
```
7171

7272
This workaround fails if the template argument is the deriving class. For example:
7373

74-
```
74+
```cpp
7575
class __declspec(dllexport) D : public B<D> {
7676
// ...
7777
```
7878

7979
Because this is common pattern with templates, the compiler changed the semantics of `dllexport` when it is applied to a class that has one or more base-classes and when one or more of the base classes is a specialization of a class template. In this case, the compiler implicitly applies `dllexport` to the specializations of class templates. You can do the following and not get a warning:
8080

81-
```
81+
```cpp
8282
class __declspec(dllexport) D : public B<D> {
8383
// ...
8484
```

docs/cpp/general-rules-for-operator-overloading.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The following rules constrain how overloaded operators are implemented. However,
5555

5656
Note that the meaning of any of the operators can be changed completely. That includes the meaning of the address-of (**&**), assignment (**=**), and function-call operators. Also, identities that can be relied upon for built-in types can be changed using operator overloading. For example, the following four statements are usually equivalent when completely evaluated:
5757

58-
```
58+
```cpp
5959
var = var + 1;
6060
var += 1;
6161
var++;

docs/cpp/goto-statement-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ goto identifier;
3333
## Example
3434
In this example, a `goto` statement transfers control to the point labeled `stop` when `i` equals 3.
3535

36-
```
36+
```cpp
3737
// goto_statement.cpp
3838
#include <stdio.h>
3939
int main()

docs/cpp/hook.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Associates a handler method with an event.
1919

2020
```
2121
22-
long __hook(
22+
long __hook(
2323
&SourceClass::EventMethod,
2424
source,
2525
&ReceiverClass::HandlerMethod

docs/cpp/how-catch-blocks-are-evaluated-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ C++ enables you to throw exceptions of any type, although in general it is recom
3636

3737
The order in which **catch** handlers appear is significant, because handlers for a given **try** block are examined in order of their appearance. For example, it is an error to place the handler for a base class before the handler for a derived class. After a matching **catch** handler is found, subsequent handlers are not examined. As a result, an ellipsis **catch** handler must be the last handler for its **try** block. For example:
3838

39-
```
39+
```cpp
4040
// ...
4141
try
4242
{

0 commit comments

Comments
 (0)