defaultvalue

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at defaultvalue. Allows specification of a default value for a typed optional parameter.

  
[ defaultvalue= value ]  

Parameters

value
The default value for the parameter.

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

The following code shows an interface method using the defaultvalue attribute:

// cpp_attr_ref_defaultvalue.cpp  
// compile with: /LD  
#include <windows.h>  
  
[export] typedef long HRESULT;  
[export, ptr, string] typedef unsigned char * MY_STRING_TYPE;  
  
[  uuid("479B29EE-9A2C-11D0-B696-00A0C903487A"),  
   dual, oleautomation,  
   helpstring("IFireTabCtrl Interface"),  
   helpcontext(122), pointer_default(unique) ]  
  
__interface IFireTabCtrl : IDispatch {  
   [bindable, propget] HRESULT get_Size([out, retval, defaultvalue("33")] long *nSize);  
   [bindable, propput] HRESULT put_Size([in] int nSize);  
};  
  
[ module(name="ATLFIRELib", uuid="479B29E1-9A2C-11D0-B696-00A0C903487A",  
      version="1.0", helpstring="ATLFire 1.0 Type Library") ];  

Attribute Context

Applies toInterface parameter
RepeatableNo
Required attributesNone
Invalid attributesNone

For more information, see Attribute Contexts.

IDL Attributes
Parameter Attributes
out
retval
in
pointer_default
unique
Attributes Samples

Show: