Share via


defaultvalue

允许为类型化的可选参数指定默认值。

语法

[ defaultvalue= value ]

参数

value
参数的默认值。

备注

defaultvalue C++ 属性具有与 defaultvalue MIDL 属性相同的功能。

示例

以下代码显示了使用 defaultvalue 属性的接口方法

// 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") ];

要求

特性上下文
适用于 接口参数
可重复
必需的特性
无效的特性

有关详细信息,请参见 特性上下文

另请参阅

IDL 特性
参数特性
out
retval
in
pointer_default
unique