Skip to content

Commit ad70cb1

Browse files
authored
Re-apply edits for style.
1 parent f5c6d85 commit ad70cb1

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

docs/cpp/void-cpp.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: void (C++)"
33
title: "void (C++)"
4-
ms.date: 10/15/2021
4+
ms.date: 12/13/2022
55
f1_keywords: ["void_cpp"]
66
helpviewer_keywords: ["void keyword [C++]", "functions [C++], void", "pointers, void"]
77
ms.assetid: d203edba-38e6-4056-8b89-011437351057
@@ -16,22 +16,26 @@ In C++, a **`void`** pointer can point to a free function (a function that's not
1616

1717
You can't declare a variable of type **`void`**.
1818

19+
As a matter of style, the C++ Core Guidelines recommend you don't use **`void`** to specify an empty formal parameter list. For more information, see [C++ Core Guidelines NL.25: Don't use `void` as an argument type](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#nl25-dont-use-void-as-an-argument-type).
20+
1921
## Example
2022

2123
```cpp
22-
void print_num(int num)
24+
// void.cpp
25+
26+
void return_nothing()
2327
{
24-
std::cout << num << std::endl;
28+
// A void function can have a return with no argument,
29+
// or no return statement.
2530
}
2631

27-
// void.cpp
2832
void vobject; // C2182
2933
void *pv; // okay
3034
int *pint; int i;
31-
int main(void)
35+
int main()
3236
{
3337
pv = &i;
34-
// Cast optional in C required in C++
38+
// Cast is optional in C, required in C++
3539
pint = (int *)pv;
3640
}
3741
```

0 commit comments

Comments
 (0)