Skip to content

Commit 4c8bce0

Browse files
authored
Add examples for void type in cpp (#4331)
Adding examples to cpp void page to comply with the description made in the above text. Fixes #4331
1 parent 49ec212 commit 4c8bce0

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎docs/cpp/void-cpp.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@ You can't declare a variable of type **`void`**.
1919
## Example
2020

2121
```cpp
22+
void print_num(int num)
23+
{
24+
std::cout << num << std::endl;
25+
}
26+
2227
// void.cpp
2328
void vobject; // C2182
2429
void *pv; // okay
2530
int *pint; int i;
26-
int main() {
31+
int main(void)
32+
{
2733
pv = &i;
2834
// Cast optional in C required in C++
2935
pint = (int *)pv;

0 commit comments

Comments
 (0)