noncreatable

定义不能单独实例化的对象。

[noncreatable]

备注

不可创建 C++ 特性具有与 不可创建 MIDL 属性相同通过自动传递到生成的 .IDL 文件编译器。

当此属性在使用 ATL 项目中时,属性的行为更改。 除了上面的行为之外,特性也插入 OBJECT_ENTRY_NON_CREATEABLE_EX_AUTO 宏。 此宏指示为 ATL 对象无法创建外部。

示例

// cpp_attr_ref_noncreatable.cpp
// compile with: /LD
#include <unknwn.h>
[module(name="MyLib")];

[object, uuid("11111111-1111-1111-1111-111111111111")]
__interface A 
{
};

[coclass, uuid("11111111-1111-1111-1111-111111111112"), noncreatable]
class CMyClass : public A 
{
   HRESULT xx();
};

要求

属性上下文

适用对象

, struct

可重复

必需的特性

coclass

无效的特性

有关属性上下文的更多信息,请参见 属性上下文

请参见

其他资源

IDL 特性

类特性

Attributes Samples