| description | Learn more about: noncreatable | |
|---|---|---|
| title | noncreatable (C++ COM Attribute) | |
| ms.date | 10/02/2018 | |
| f1_keywords |
|
|
| helpviewer_keywords |
|
|
| ms.assetid | 4d17937b-0bff-41af-ba57-53e18b7ab5a9 |
Defines an object that cannot be instantiated by itself.
[noncreatable]The noncreatable C++ attribute has the same functionality as the noncreatable MIDL attribute and is automatically passed through to the generated .IDL file by the compiler.
When this attribute is used within a project that uses ATL, the behavior of the attribute changes. In addition to the above behavior, the attribute also injects the OBJECT_ENTRY_NON_CREATEABLE_EX_AUTO macro. This macro indicates to ATL that the object cannot be created externally.
// 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();
};| Attribute context | Value |
|---|---|
| Applies to | class, struct |
| Repeatable | No |
| Required attributes | coclass |
| Invalid attributes | None |
For more information about the attribute contexts, see Attribute Contexts.