Skip to content

Commit 13a89f6

Browse files
authored
Merge pull request MicrosoftDocs#3655 from corob-msft/docs/corob/cpp-docs-3223
Make extra fixes spotted in 3223
2 parents abf383f + d6c5667 commit 13a89f6

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

docs/cpp/template-specialization-cpp.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: Template Specialization (C++)"
33
title: "Template Specialization (C++)"
4-
ms.date: "11/04/2016"
4+
ms.date: 07/09/2021
55
helpviewer_keywords: ["partial specialization of class templates"]
66
ms.assetid: f3c67c0b-3875-434a-b8d8-bb47e99cf4f0
77
---
@@ -17,6 +17,8 @@ Class templates can be partially specialized, and the resulting class is still a
1717

1818
```cpp
1919
// partial_specialization_of_class_templates.cpp
20+
#include <stdio.h>
21+
2022
template <class T> struct PTS {
2123
enum {
2224
IsPointer = 0,
@@ -40,24 +42,25 @@ template <class T, class U> struct PTS<T U::*> {
4042

4143
struct S{};
4244

43-
extern "C" int printf_s(const char*,...);
44-
4545
int main() {
46-
printf_s("PTS<S>::IsPointer == %d PTS<S>::IsPointerToDataMember == %d\n",
46+
printf_s("PTS<S>::IsPointer == %d \nPTS<S>::IsPointerToDataMember == %d\n",
4747
PTS<S>::IsPointer, PTS<S>:: IsPointerToDataMember);
48-
printf_s("PTS<S*>::IsPointer == %d PTS<S*>::IsPointerToDataMember ==%d\n"
48+
printf_s("PTS<S*>::IsPointer == %d \nPTS<S*>::IsPointerToDataMember == %d\n"
4949
, PTS<S*>::IsPointer, PTS<S*>:: IsPointerToDataMember);
50-
printf_s("PTS<int S::*>::IsPointer == %d PTS"
50+
printf_s("PTS<int S::*>::IsPointer == %d \nPTS"
5151
"<int S::*>::IsPointerToDataMember == %d\n",
5252
PTS<int S::*>::IsPointer, PTS<int S::*>::
5353
IsPointerToDataMember);
5454
}
5555
```
5656
5757
```Output
58-
PTS<S>::IsPointer == 0 PTS<S>::IsPointerToDataMember == 0
59-
PTS<S*>::IsPointer == 1 PTS<S*>::IsPointerToDataMember ==0
60-
PTS<int S::*>::IsPointer == 0 PTS<int S::*>::IsPointerToDataMember == 1
58+
PTS<S>::IsPointer == 0
59+
PTS<S>::IsPointerToDataMember == 0
60+
PTS<S*>::IsPointer == 1
61+
PTS<S*>::IsPointerToDataMember == 0
62+
PTS<int S::*>::IsPointer == 0
63+
PTS<int S::*>::IsPointerToDataMember == 1
6164
```
6265

6366
## Example: Partial specialization for pointer types
@@ -159,6 +162,7 @@ int main() {
159162
xp.add(&j);
160163
xp.add(p);
161164
xp.add(p + 1);
165+
delete[] p;
162166
p = NULL;
163167
xp.add(p);
164168
xp.print();

0 commit comments

Comments
 (0)