Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
optional

optional

Specifies an optional parameter for a member function.

[optional]

Attribute Context

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

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

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);
};

See Also

IDL Attributes | Parameter Attributes | Attributes Samples

Show:
© 2015 Microsoft