データ メンバーへの割り当てを禁止します。
構文
[readonly]
解説
readonly C++ 属性には、 readonly MIDL 属性と同じ機能があります。
メソッド パラメーターの変更を禁止する場合は、 in 属性を使用します。
例
readonly 属性の使用方法は、次のコードのとおりです。
// 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();
};
要件
| 属性コンテキスト | 値 |
|---|---|
| 適用対象 | インターフェイス メソッド |
| 反復可能 | いいえ |
| 必要な属性 | なし |
| 無効な属性 | なし |
属性コンテキストの詳細については、「 属性コンテキスト」を参照してください。