Skip to content

Commit 2c74a24

Browse files
author
Colin Robertson
authored
Merge pull request #2919 from MicrosoftDocs/master
Publish \<span> docs to live
2 parents 426e327 + 7ececd9 commit 2c74a24

6 files changed

Lines changed: 1276 additions & 19 deletions

File tree

‎docs/cpp/pointers-to-members.md‎

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class Window
5555
public:
5656
Window(); // Default constructor.
5757
Window( int x1, int y1, // Constructor specifying
58-
int x2, int y2 ); // window size.
59-
bool SetCaption( const char *szTitle ); // Set window caption.
58+
int x2, int y2 ); // Window size.
59+
bool SetCaption( const char *szTitle ); // Set window caption.
6060
const char *GetCaption(); // Get window caption.
6161
char *szWinCaption; // Window caption.
6262
};
@@ -71,23 +71,24 @@ int main()
7171
In the preceding example, `pwCaption` is a pointer to any member of class `Window` that's of type `char*`. The type of `pwCaption` is `char * Window::*`. The next code fragment declares pointers to the `SetCaption` and `GetCaption` member functions.
7272
7373
```cpp
74-
const char * (Window::*pfnwGC)() = &Window::GetCaption;
75-
bool (Window::*pfnwSC)( const char * ) = &Window::SetCaption;
74+
const char * (Window::* pfnwGC)() = &Window::GetCaption;
75+
bool (Window::* pfnwSC)( const char * ) = &Window::SetCaption;
7676
```
7777

7878
The pointers `pfnwGC` and `pfnwSC` point to `GetCaption` and `SetCaption` of the `Window` class, respectively. The code copies information to the window caption directly using the pointer to member `pwCaption`:
7979

8080
```cpp
81-
Window wMainWindow;
81+
Window wMainWindow;
8282
Window *pwChildWindow = new Window;
8383
char *szUntitled = "Untitled - ";
84-
int cUntitledLen = strlen( szUntitled );
84+
int cUntitledLen = strlen( szUntitled );
8585

8686
strcpy_s( wMainWindow.*pwCaption, cUntitledLen, szUntitled );
87-
(wMainWindow.*pwCaption)[cUntitledLen - 1] = '1'; //same as
88-
//wMainWindow.SzWinCaption [cUntitledLen - 1] = '1';
87+
(wMainWindow.*pwCaption)[cUntitledLen - 1] = '1'; // same as
88+
// wMainWindow.SzWinCaption [cUntitledLen - 1] = '1';
8989
strcpy_s( pwChildWindow->*pwCaption, cUntitledLen, szUntitled );
90-
(pwChildWindow->*pwCaption)[cUntitledLen - 1] = '2'; //same as //pwChildWindow->szWinCaption[cUntitledLen - 1] = '2';
90+
(pwChildWindow->*pwCaption)[cUntitledLen - 1] = '2'; // same as
91+
// pwChildWindow->szWinCaption[cUntitledLen - 1] = '2';
9192
```
9293
9394
The difference between the **`.*`** and **`->*`** operators (the pointer-to-member operators) is that the **`.*`** operator selects members given an object or object reference, while the **`->*`** operator selects members through a pointer. For more information about these operators, see [Expressions with Pointer-to-Member Operators](../cpp/pointer-to-member-operators-dot-star-and-star.md).
@@ -131,24 +132,24 @@ using namespace std;
131132

132133
class Base
133134
{
134-
public:
135+
public:
135136
virtual void Print();
136137
};
137-
void (Base ::* bfnPrint)() = &Base :: Print;
138-
void Base :: Print()
138+
void (Base::* bfnPrint)() = &Base::Print;
139+
void Base::Print()
139140
{
140-
cout << "Print function for class Base\n";
141+
cout << "Print function for class Base" << endl;
141142
}
142143

143144
class Derived : public Base
144145
{
145-
public:
146+
public:
146147
void Print(); // Print is still a virtual function.
147148
};
148149

149-
void Derived :: Print()
150+
void Derived::Print()
150151
{
151-
cout << "Print function for class Derived\n";
152+
cout << "Print function for class Derived" << endl;
152153
}
153154

154155
int main()
@@ -162,6 +163,7 @@ int main()
162163
(bPtr->*bfnPrint)();
163164
}
164165

165-
//Output: Print function for class Base
166-
Print function for class Derived
166+
// Output:
167+
// Print function for class Base
168+
// Print function for class Derived
167169
```

‎docs/standard-library/cpp-standard-library-header-files.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Header files for the C++ standard library and extensions, by category.
2323
| Ordered associative containers| [\<map>](map.md), [\<set>](set.md) |
2424
| Unordered associative containers | [\<unordered_map>](unordered-map.md)<sup>11</sup>, [\<unordered_set>](unordered-set.md)<sup>11</sup> |
2525
| Container adaptors | [\<queue>](queue.md), [\<stack>](stack.md) |
26-
| Container views | \<span><sup>20</sup> |
26+
| Container views | [\<span>](span.md)<sup>20</sup> |
2727
| [Errors and exception handling](../cpp/errors-and-exception-handling-modern-cpp.md) | [\<cassert>](cassert.md), [\<exception>](exception.md), [\<stdexcept>](stdexcept.md), [\<system_error>](system-error.md)<sup>11</sup> |
2828
| General utilities | \<any><sup>17</sup>, [\<bitset>](bitset.md), \<charconv><sup>17</sup>, [\<cstdlib>](cstdlib.md), \<execution><sup>17</sup>, [\<functional>](functional.md), [\<memory>](memory.md), \<memory_resource><sup>17</sup>, \<optional><sup>17</sup>, [\<ratio>](ratio.md)<sup>11</sup>, [\<scoped_allocator>](scoped-allocator.md)<sup>11</sup>, [\<tuple>](tuple.md)<sup>11</sup>, [\<type_traits>](type-traits.md)<sup>11</sup>, [\<typeindex>](typeindex.md)<sup>11</sup>, [\<utility>](utility.md), \<variant><sup>17</sup> |
2929
| [I/O and formatting](../text/string-and-i-o-formatting-modern-cpp.md) | [\<cinttypes>](cinttypes.md)<sup>11</sup>, [\<cstdio>](cstdio.md), [\<filesystem>](filesystem.md)<sup>17</sup>, [\<fstream>](fstream.md), [\<iomanip>](iomanip.md), [\<ios>](ios.md), [\<iosfwd>](iosfwd.md), [\<iostream>](iostream.md), [\<istream>](istream.md), [\<ostream>](ostream.md), [\<sstream>](sstream.md), [\<streambuf>](streambuf.md), [\<strstream>](strstream.md)<sup>c</sup>, \<syncstream><sup>20</sup> |

0 commit comments

Comments
 (0)