source (C++)

 

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

On a class, specifies the COM object's source interfaces for connection points. On a property or method, indicates that the member returns an object or VARIANT that is a source of events.

  
      [ source(  
   interfaces  
) ]  

Parameters

interfaces
One or more interfaces that you specify when you apply the source attribute to a class. This parameter is not used when source is applied to a property or method.

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

You can use the default attribute to specify the default source interface for an object.

// cpp_attr_ref_source.cpp  
// compile with: /LD  
#include "windows.h"  
#include "unknwn.h"  
[module(name="MyLib")];  
  
[object, uuid(11111111-1111-1111-1111-111111111111)]  
__interface b  
{  
   [id(0), propget, bindable, displaybind, defaultbind, requestedit]  
   HRESULT get_I([out, retval]long *i);  
};  
  
[object, uuid(11111111-1111-1111-1111-111111111131)]  
__interface c  
{  
   [id(0), propget, bindable, displaybind, defaultbind, requestedit]   
   HRESULT et_I([out, retval]long *i);  
};  
  
[coclass, default(c), uuid(11111111-1111-1111-1111-111111111132)]  
class N : public b  
{  
};  
  
[coclass, source(c), default(b, c), uuid(11111111-1111-1111-1111-111111111133)]  
class NN : public b  
{  
};  

Attribute Context

Applies toclass, struct, interface
RepeatableNo
Required attributescoclass (when applied to class or struct)
Invalid attributesNone

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

IDL Attributes
Class Attributes
Method Attributes
coclass
Attributes Samples

Show: