Skip to content

Latest commit

 

History

History
74 lines (63 loc) · 1.8 KB

File metadata and controls

74 lines (63 loc) · 1.8 KB
title void (C++) | Microsoft Docs
ms.custom
ms.date 11/04/2016
ms.reviewer
ms.suite
ms.technology
devlang-cpp
ms.tgt_pltfrm
ms.topic language-reference
f1_keywords
void
void_cpp
dev_langs
C++
helpviewer_keywords
void keyword [C++]
functions [C++], void
pointers, void
ms.assetid d203edba-38e6-4056-8b89-011437351057
caps.latest.revision 9
author mikeblome
ms.author mblome
manager ghogen
translation.priority.ht
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw
translationtype Human Translation
ms.sourcegitcommit f7f8be19019262c367ab9828a89549f028991d58
ms.openlocfilehash 4102f1a994b3d9fb404737f01300927c20f9c74f

void (C++)

When used as a function return type, the void keyword specifies that the function does not return a value. When used for a function's parameter list, void specifies that the function takes no parameters. When used in the declaration of a pointer, void specifies that the pointer is "universal."

If a pointer's type is void *, the pointer can point to any variable that is not declared with the const or volatile keyword. A void pointer cannot be dereferenced unless it is cast to another type. A void pointer can be converted into any other type of data pointer.

A void pointer can point to a function, but not to a class member in C++.

You cannot declare a variable of type void.

Example

// void.cpp  
void vobject;   // C2182  
void *pv;   // okay  
int *pint; int i;  
int main() {  
   pv = &i;  
   // Cast optional in C required in C++  
   pint = (int *)pv;  
}   

See Also

Keywords
Fundamental Types