--- title: "source (C++) | Microsoft Docs" ms.custom: "" ms.date: "11/04/2016" ms.reviewer: "" ms.suite: "" ms.technology: - "cpp-windows" ms.tgt_pltfrm: "" ms.topic: "language-reference" f1_keywords: - "vc-attr.source" dev_langs: - "C++" helpviewer_keywords: - "source attribute" ms.assetid: 1878d05d-7709-4e97-b114-c62f38f5140e caps.latest.revision: 9 author: "mikeblome" ms.author: "mblome" manager: "ghogen" translation.priority.ht: - "cs-cz" - "de-de" - "es-es" - "fr-fr" - "it-it" - "ja-jp" - "ko-kr" - "pl-pl" - "pt-br" - "ru-ru" - "tr-tr" - "zh-cn" - "zh-tw" --- # source (C++) 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. ## Syntax ``` [ 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. ## Remarks The **source** C++ attribute has the same functionality as the [source](http://msdn.microsoft.com/library/windows/desktop/aa367166) MIDL attribute. You can use the [default](../windows/default-cpp.md) attribute to specify the default source interface for an object. ## Example ``` // 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 { }; ``` ## Requirements ### Attribute Context ||| |-|-| |**Applies to**|**class**, `struct`, `interface`| |**Repeatable**|No| |**Required attributes**|**coclass** (when applied to class or struct)| |**Invalid attributes**|None| For more information about the attribute contexts, see [Attribute Contexts](../windows/attribute-contexts.md). ## See Also [IDL Attributes](../windows/idl-attributes.md) [Class Attributes](../windows/class-attributes.md) [Method Attributes](../windows/method-attributes.md) [coclass](../windows/coclass.md)