Skip to content

Latest commit

 

History

History
86 lines (72 loc) · 1.9 KB

File metadata and controls

86 lines (72 loc) · 1.9 KB
title readonly (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.readonly
dev_langs
C++
helpviewer_keywords
readonly attribute
ms.assetid 1246cadd-5304-43a9-beea-51153d12704d
caps.latest.revision 9
author mikeblome
ms.author mblome
manager ghogen
translation.priority.ht
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
ru-ru
zh-cn
zh-tw
translation.priority.mt
cs-cz
pl-pl
pt-br
tr-tr

readonly (C++)

Prohibits assignment to a data member.

Syntax

  
[readonly]  
  

Remarks

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

If you want to prohibit modification of a method parameter, then use the in attribute.

Example

The following code shows a use of the readonly attribute:

// cpp_attr_ref_readonly.cpp  
// compile with: /LD  
[idl_quote("midl_pragma warning(disable:2461)")];  
#include "unknwn.h"  
[module(name="ATLFIRELib")];  
  
[dispinterface, uuid(11111111-1111-1111-1111-111111111111)]  
__interface IFireTabCtrl  
{  
   [readonly, id(1)] int i();  
};  

Requirements

Attribute Context

Applies to Interface method
Repeatable No
Required attributes None
Invalid attributes None

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

See Also

IDL Attributes
Data Member Attributes