'attribute': 属性を繰り返して使用できません
複数回出現する属性がターゲットに適用されないように、いくつかの属性が宣言されます。
詳細については、「 User-Defined Attributes」を参照してください。
例
次の例では C3095 が生成されます。
// C3095.cpp
// compile with: /clr /c
using namespace System;
[AttributeUsage(AttributeTargets::All, AllowMultiple=false)]
public ref class Attr : public Attribute {
public:
Attr(int t) : m_t(t) {}
const int m_t;
};
[AttributeUsage(AttributeTargets::All, AllowMultiple=true)]
public ref class Attr2 : public Attribute {
public:
Attr2(int t) : m_t(t) {}
const int m_t;
};
[Attr(10)] // C3095
[Attr(11)]
ref class A {};
[Attr2(10)] // OK
[Attr2(11)]
ref class B {};