Skip to content

Latest commit

 

History

History
82 lines (69 loc) · 1.76 KB

File metadata and controls

82 lines (69 loc) · 1.76 KB
title optional (C++) | Microsoft Docs
ms.custom
ms.date 11/04/2016
ms.reviewer
ms.suite
ms.technology
cpp-windows
ms.tgt_pltfrm
ms.topic language-reference
f1_keywords
vc-attr.optional
dev_langs
C++
helpviewer_keywords
optional attribute
ms.assetid 86656a66-8e11-4589-8e30-9b0f34eeed03
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

optional (C++)

Specifies an optional parameter for a member function.

Syntax

  
[optional]  
  

Remarks

The optional C++ attribute has the same functionality as the optional MIDL attribute.

Example

The following code shows how optional might be used:

// cpp_attr_ref_optional.cpp  
// compile with: /LD  
#include "unknwn.h"  
[module(name="ATLFIRELib")];  
  
[dispinterface, uuid("00000000-0000-0000-0000-000000000001")]  
__interface IFireTabCtrl : IDispatch  
{  
   [id(1)] long procedure ([in, optional] VARIANT i);  
};  

Requirements

Attribute Context

Applies to Interface parameter
Repeatable No
Required attributes None
Invalid attributes None

For more information about the attribute contexts, see Attribute Contexts.

See Also

IDL Attributes
Parameter Attributes